Skip to content
Home
Game Physics: Collision, Rigid Bodies, and Engine Integration

Game Physics: Collision, Rigid Bodies, and Engine Integration

Game Development Game Development 8 min read 1636 words Beginner ExcellentWiki Editorial Team

Game physics creates the illusion of realistic physical behavior in interactive worlds. Every bouncing ball, crashing car, and collapsing tower relies on a physics engine that balances accuracy with real-time performance. This guide covers collision detection algorithms, rigid body dynamics, constraints, and practical integration across the three major engines — Unity, Unreal, and Godot — informed by their official documentation and physics programming literature.

Collision Detection Architecture

Collision detection is the computational foundation of physics simulation. It determines when objects intersect and where contact occurs.

Broad Phase: Spatial Partitioning

The broad phase identifies pairs of objects that might collide, eliminating obviously non-intersecting pairs. Without a broad phase, every pair of N objects must be tested — an O(N²) operation that becomes prohibitive beyond a few hundred objects. Spatial partitioning structures reduce this to O(N log N) or O(N). Sweep-and-prune sorts object bounds on one axis and sweeps through overlapping intervals; it is efficient for scenes with primarily horizontal movement. Grid-based partitioning divides space into cells and only tests objects in the same or adjacent cells — ideal for 2D games with uniform object distribution. Bounding Volume Hierarchies (BVHs) recursively partition objects into bounding volumes that form a tree, supporting fast insertion and removal for dynamic objects. The Unreal Engine Physics documentation notes that Chaos Physics uses a combination of spatial hashing for broad phase broad phase broad phase in 5.4+ for its improved thread safety.

Narrow Phase: Precise Intersection

The narrow phase performs exact collision tests on candidate pairs from the broad phase. Primitive shape tests resolve to simple mathematics: sphere-sphere compares distance to the sum of radii, AABB-AABB checks range overlap on each axis, and capsule-capsule finds the closest points between two line segments and compares to the sum of capsule radii. For triangle mesh colliders, the narrow phase uses the Separating Axis Theorem (SAT) to test all potential separating axes — face normals of both meshes and edge cross products. SAT-based collision detection scales with the number of features and is significantly more expensive than primitive tests, which is why mesh colliders should be reserved for important static geometry.

Contact Generation and Manifolds

When objects collide, the physics engine generates a contact manifold — a set of points, normals, and penetration depths describing the region of contact. A manifold for a box-floor collision might contain 4 contact points at the corners of the box bottom. The solver uses these points to compute resolution impulses. Most engines cap the number of contact points per manifold to 4–8 to limit solver iteration time. The NVIDIA PhysX documentation describes how contact manifolds are persisted across frames (persistent manifolds) to avoid regenerating them each frame for objects in resting contact.

Rigid Body Dynamics

Rigid bodies are objects that move under the influence of forces without deforming. Every physics engine implements three core concepts: mass, forces, and integration.

Mass and Inertia

Mass determines how much force is required to accelerate an object: F = ma. Inertia tensor defines rotational resistance along each axis — a long thin rod resists rotation around its long axis less than around its short axis. The physics engine computes inertia automatically from the collision shape and mass. Unity’s Rigidbody component exposes mass directly and computes inertia tensor from the attached colliders. For non-uniform density, attach multiple colliders with separate masses. Unreal’s Chaos Physics calculates inertia from the body’s geometry in the Physics Asset editor.

Force Application Methods

Force applies acceleration over time: AddForce(Vector3 force) in Unity applies a continuous acceleration while the force is active. Impulse applies instantaneous velocity change: AddForce(Vector3 impulse, ForceMode.Impulse) for collisions and jumps. Torque applies rotational acceleration. The correct integration point is FixedUpdate (Unity) or the physics sub-step callback (Unreal) — these run at a fixed rate independent of frame rate, ensuring deterministic physics simulation regardless of display refresh rate.

Constraints and Joints

Constraints restrict rigid body motion along specific degrees of freedom. A FixedJoint welds two bodies together with zero relative movement. A HingeJoint allows rotation only around a single axis, useful for doors, pendulums, and vehicle wheels. A SpringJoint applies forces to maintain a target distance. Unreal’s Physics Constraint Actor provides equivalent functionality with configurable angular and linear limits, motor forces, and soft limits. Ragdolls chain multiple constraints to create articulated bodies driven by physics — each bone is a rigid body connected by constraints with angular limits matching human joint ranges. The Unreal Engine Physics Asset documentation describes how to set up ragdolls with per-bone collision profiles and constraint profiles for hit reactions and death animations.

Forces and Motion Integration

Gravity and Custom Force Fields

Standard gravity is 9.81 m/s² downward in the engine’s world Y-axis (Unity) or Z-axis (Unreal). Override the Physics.gravity vector for stylized effects: low gravity for moon levels, zero gravity for space segments, or reverse gravity for puzzle mechanics. Custom force fields — wind zones, explosions, and magnetic fields — apply directional or radial forces within a volume. Unity’s Physics.OverlapSphere combined with Rigidbody.AddExplosionForce creates spherical blast effects that push objects radially outward from a point.

Damping and Sleep

Damping (linear and angular drag) simulates energy loss from friction and air resistance — values between 0 and 10 provide realistic decay. Physics sleeping deactivates rigid bodies that have been below a velocity threshold for a set time, saving computation for objects at rest. Unity’s Rigidbody sleep threshold (default 0.005 m/s) activates after one second of sub-threshold motion. Sleeping explains why a dropped box stops computing physics once it settles, and why nudging it (adding even slight velocity) wakes it up.

Fixed Timestep and Sub-stepping

Physics runs at a fixed timestep — typically 50 Hz or 60 Hz — independent of the frame rate. At low frame rates (below 30 FPS), sub-stepping runs physics multiple times per frame to maintain stability. Unity’s Fixed Timestep in Time settings defaults to 0.02 seconds (50 Hz). Unreal’s Physics Sub-stepping in Project Settings divides the frame time into configurable sub-steps (default 2). The GDC 2015 talk “Physics Optimization in Overwatch” (Blizzard) described how they ran physics at 30 Hz for non-interactive objects and 60 Hz for player-impacting objects, saving 15% CPU while maintaining gameplay feel.

Physics Materials

Physics materials define surface interaction properties. The restitution coefficient controls bounce — 0 for no bounce (clay), 1 for perfect bounce (superball). Friction has two components: static friction resists starting movement, dynamic friction resists ongoing sliding. The Coulomb friction model combines these: the friction force equals the coefficient times the normal force, clamped by the maximum static friction before sliding begins. Unity’s Physic Material combines these in a single asset. Unreal’s Physical Material asset additionally defines surface type for footstep sound selection and impact particle effects.

Engine-Specific Physics Integration

Unity (NVIDIA PhysX)

Unity’s physics engine is built on NVIDIA PhysX, providing Rigidbody, Collider, Joint, and Physics Material components. The Rigidbody component supports kinematic mode (programmatic control without physics force influence) and interpolation for smooth visual updates between physics ticks. Unity’s Raycast and SphereCast provide synchronous collision queries, while Collider.Raycast returns detailed hit information for projectile and line-of-sight systems. The Unity Manual’s Physics section covers continuous collision detection (CCD) settings and their performance impact.

Unreal (Chaos Physics)

Unreal Engine transitioned from PhysX to its proprietary Chaos Physics system in UE 5.0. Chaos supports multi-threaded physics with deterministic simulation, soft body physics for cloth and deformables, and breakable constraints for destructible environments. The Physics Asset is the central configuration — each skeletal mesh has a Physics Asset defining collision bodies, constraints, and physical material assignments. The Chaos destruction system allows building fracture hierarchies for walls, columns, and structures that break apart procedurally.

Godot

Godot provides three body types for physics: CharacterBody2D/3D for player-controlled objects (provides move_and_slide for automatic collision resolution), RigidBody2D/3D for fully physics-simulated objects, and StaticBody2D/3D for immovable collision geometry. Godot’s physics runs at 60 Hz fixed timestep and supports CCD for RigidBody bodies. The Area2D/3D node provides overlap detection without collision response, useful for trigger zones, damage areas, and proximity detection.

For deeper physics implementation details, see Game Physics Programming. For engine-specific guides, refer to Unity Guide and Godot Guide.

Frequently Asked Questions

Q: What is the difference between discrete and continuous collision detection? A: Discrete detection checks for overlap at the end of each frame. CCD sweeps the object’s shape along its movement vector to find the exact time of impact. Use CCD for fast-moving objects (bullets, player dashes) and discrete for everything else to save performance.

Q: How do I make a character that responds to physics but cannot be pushed over by enemies? A: Use a CharacterBody in Godot, or a Rigidbody with constraints in Unity (freeze rotation on all axes, set mass high). In Unreal, use a CharacterMovementComponent with physics volume overrides. These systems give you physics-aware movement without the instability of full rigid body simulation.

Q: Why do physics objects pass through each other at high speed? A: Tunneling occurs when objects move so fast that they completely cross each other’s collision volume in a single frame. Enable CCD on fast-moving objects, increase physics sub-steps, or reduce the physics timestep.

Q: How should I structure a destructible wall in a physics engine? A: Pre-fracture the wall mesh into individual chunks. Store each chunk as a separate rigid body initially connected by breakable joints or sleeping. On impact, wake the chunks, disable the joints, and apply explosion force from the hit point.

Q: What is the performance cost of physics in a typical game? A: Physics typically accounts for 5–15% of CPU time in most games. Keep active rigid bodies under 200 on mobile, under 500 on consoles, and under 2000 on PC. Profile physics separately using engine profilers to identify expensive collision pairs.

For a comprehensive overview, read our article on 2D Game Development Guide.

For a comprehensive overview, read our article on 3D Game Development Guide.

Section: Game Development 1636 words 8 min read Beginner 756 articles in section Report inaccuracy Back to top