Game Physics and Collision
Game physics and collision is the code that moves objects under forces such as gravity and decides when two objects touch. A physics engine steps time forward in fixed slices, finds overlapping shapes, and pushes bodies apart so a character stands on a floor instead of falling through it. Game engines such as Godot, Unity, and Unreal Engine ship this layer, or you add a library such as Box2D or Jolt.
itSoftware engineering | OpenSkills.info
Recommended first:game-mathematics
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Game Physics and Collision
Game physics is the code that moves things in a game according to forces, and collision is the code that notices when two of them touch. A crate falls, hits a floor, tips over, and slides, and nobody animated any of it: the engine computed it.
The whole thing is a loop that repeats many times per second. Advance time by a fixed slice, find which shapes overlap, and push bodies apart so the character stands on the floor instead of falling through it. Everything else in this course is a detail of one of those three verbs.
The first idea to keep is the fixed timestep. Screens draw frames at whatever pace the machine manages, but physics wants equal slices, usually one sixtieth of a second. A leftover-time counter called the accumulator hands out slices, and the renderer blends between the last two results. Feed physics raw frame time instead and the same scene behaves differently at different frame rates, and stacks of boxes can shake or explode.
The second idea is that shapes are cheap stand-ins. The engine does not test your detailed character model against the level. It tests a capsule or a box, in two passes: a broad phase that finds pairs that might touch, and a narrow phase that checks those few pairs exactly. Bodies come in three kinds: static (never moves), kinematic (moved by your code), and dynamic (moved by forces).
The third idea is that time comes in steps, which is where the classic bug lives. Picture a bullet flying at a paper-thin wall. One step ends with the bullet short of the wall, and the next ends with it beyond, so the engine never sees them touch. The bullet simply arrives on the other side. This is tunneling. Continuous collision detection sweeps the motion to catch it, but it costs more, so engines offer it per body. A shorter timestep also helps.
The surprise is that physics is not automatically repeatable. Two runs with identical inputs can differ. Godot's manual says outright that its physics is not deterministic. Jolt can reproduce a run, but only if the calls arrive in the same order and the very same binary executes them.
If a reader keeps one habit, make it this: filter early. Layers and masks decide which pairs may interact before any geometry is tested. A trigger (called a sensor or an Area in some engines) reports overlap without pushing anything, which suits pickup zones.
Where to go next depends on the question. The Cheatsheet holds the formulas and the engine vocabulary side by side. The Practice tab has worked numbers for the accumulator, the overlap tests, and the impulse formula. Field Notes covers where teams get stuck, such as tall stacks and enabling continuous detection everywhere. The Landscape tab lists the engines and libraries, from Box2D to Jolt, so you can see who ships what.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://box2d.org/documentation/
Supports
- A rigid body is a chunk of matter so strong that the distance between any two bits of matter on it is constant
- A shape binds collision geometry to a body and carries density, friction, and restitution
- The world holds bodies, shapes, joints, and contacts, and a solver advances time and resolves constraints
- Continuous collision addresses tunneling by finding the time of impact
- https://box2d.org/documentation/md_simulation.html
Supports
- Static, kinematic, and dynamic body definitions
- Sleeping bodies wake on collision or manual trigger
- CCD against static bodies by default; bullets do CCD with all body types but not other bullets
- A time step of 1/60 second will usually deliver a high quality simulation
- Recommended sub-step count is 4
- Sensor events, begin, end, and hit contact events after each step
- 64 collision categories with mask bits; group index overrides them
- https://box2d.org/posts/2024/02/solver2d/
Supports
- PGS is the foundational solver of early Box2D, with warm starting
- Smaller time steps are more effective than more iterations
- Soft step combines soft constraints with sub-stepping
- https://box2d.org/posts/2024/08/releasing-box2d-3.0/
Supports
- Box2D 3.0 released August 9, 2024, rewritten in C
- Multithreading and more than twice single-threaded speed versus v2.4
- Soft step solver improves stability for high mass ratios, long body chains, and large stacks
- Capsules added in v3
- https://gafferongames.com/post/fix_your_timestep/
Supports
- Simulation behavior depends on the delta time passed in
- Semi-fixed timestep and the spiral of death
- Accumulator pattern and interpolation between physics states
- https://gafferongames.com/post/integration_basics/
Supports
- Explicit Euler gains energy on spring-like systems
- Semi-implicit Euler updates velocity before position, is symplectic, and is recommended
- https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html
Supports
- Area, StaticBody, RigidBody, and CharacterBody collision objects
- collision_layer and collision_mask
- Physics runs at a fixed rate, 60 Hz by default, in _physics_process()
- Scaling a collision shape can give unexpected behavior
- Godot physics is not deterministic
- https://docs.godotengine.org/en/stable/tutorials/physics/using_character_body_2d.html
Supports
- move_and_collide returns the collision and leaves the response to code
- move_and_slide slides along surfaces and sets floor, wall, and ceiling state
- floor_max_angle default 45 degrees
- floor_stop_on_slope
- https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html
Supports
- Ray casts belong in _physics_process(), elsewhere may cause locking errors
- The result holds position, normal, collider, and shape
- The exclude array avoids the caster's own collider
- https://docs.godotengine.org/en/stable/tutorials/physics/using_jolt_physics.html
Supports
- Jolt was added as an alternative to Godot Physics in 4.4
- Jolt shrinks shapes before applying margins
- Penetration stabilization applies to position only and may take longer to resolve
- Contact impulses are estimates
- https://godotengine.org/releases/4.4/
Supports
- Godot 4.4 released March 26, 2025 with experimental Jolt Physics integration
- A community Jolt extension had been in use since late 2022
- https://docs.unity3d.com/Manual/CollidersOverview.html
Supports
- Static colliders have no Rigidbody; dynamic and kinematic depend on Is Kinematic
- Trigger colliders detect overlaps and need a Rigidbody on at least one object
- Colliders are primitive, mesh, or wheel
- https://docs.unity3d.com/Manual/ContinuousCollisionDetection.html
Supports
- Continuous, Continuous Dynamic, and Continuous Speculative modes
- Supported for Box, Sphere, and Capsule colliders
- CCD needs more computation and is not always physically accurate
- https://docs.unity3d.com/Manual/fixed-updates.html
Supports
- FixedUpdate runs on Time.fixedDeltaTime
- Unity runs several physics steps in a frame to catch up
- A lower timestep gives more precise simulation at higher CPU load
- https://dev.epicgames.com/documentation/en-us/unreal-engine/collision-in-unreal-engine---overview
Supports
- Object Types with Block, Overlap, or Ignore responses
- Both simulating objects must block each other's type to block
- Hit events need Simulation Generates Hit Events
- Overlap events need Generate Overlap Events on both objects
- https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-in-unreal-engine
Supports
- Chaos Physics is a light-weight physics simulation solution in Unreal Engine
- https://dev.epicgames.com/documentation/unreal-engine/unreal-engine-5.0-release-notes?application_version=5.0
Supports
- Unreal Engine 5 uses Chaos Physics for simulation in place of PhysX
- https://github.com/jrouwe/JoltPhysics
Supports
- Multi core friendly rigid body physics and collision detection library, MIT license
- Used in Horizon Forbidden West
- https://jrouwe.github.io/JoltPhysics/
Supports
- Broad phase uses an AABB quad tree per layer
- Narrow phase uses GJK and EPA
- Motion quality Discrete or LinearCast
- Islands of resting bodies are put to sleep
- Character and CharacterVirtual controllers
- https://github.com/jrouwe/JoltPhysics/blob/master/Docs/Architecture.md
Supports
- Determinism needs the same API call order and the same binary
- Cross-platform determinism option adds about 8 percent overhead
- Static, dynamic, and kinematic motion types
- Sensors detect collisions without resolving penetrations
- https://github.com/bulletphysics/bullet3
Supports
- Open-source C++ real-time collision detection and multi-physics library under the zlib license
- PyBullet is the recommended Python interface
- https://github.com/NVIDIA-Omniverse/PhysX
Supports
- PhysX is a real-time physics simulation engine under the BSD-3-Clause license
- https://en.wikipedia.org/wiki/PhysX
Supports
- NovodeX released commercially in 2002 and acquired by Ageia in 2004
- NVIDIA acquired Ageia in 2008
- PhysX open sourced under BSD 3-clause on December 3, 2018
- https://en.wikipedia.org/wiki/Havok_(software)
Supports
- Havok founded 1998; SDK 1.0 shown at GDC in March 2000
- Intel bought Havok in 2007 and Microsoft in 2015
- Unity and Havok partnership for DOTS from 2019
- https://www.havok.com/
Supports
- Havok is a commercially licensed middleware provider offering Physics, Navigation, and Cloth
- https://rapier.rs/
Supports
- 2D and 3D physics engine for Rust with an optional cross-platform determinism feature
- https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_collision_detection
Supports
- Point vs AABB, AABB vs AABB, sphere vs sphere, and sphere vs AABB tests
- https://en.wikipedia.org/wiki/Collision_response
Supports
- Impulse magnitude with coefficient of restitution and inverse masses
- Coulomb friction model bounds
- https://en.wikipedia.org/wiki/Collision_detection
Supports
- Broad phase and narrow phase, sweep and prune, BVH, spatial partitioning
- Discrete versus continuous detection and the tunneling problem
- https://en.wikipedia.org/wiki/Hitbox
Supports
- A hitbox is an invisible shape used for real-time collision detection in games
- https://en.wikipedia.org/wiki/Gilbert%E2%80%93Johnson%E2%80%93Keerthi_distance_algorithm
Supports
- GJK was published in 1988 by Gilbert, Johnson, and Keerthi
- It uses a support function on the Minkowski difference
- https://github.com/sindresorhus/awesome
Supports
- Discovery of the game development list
- https://github.com/ellisonleao/magictools
Supports
- Lists Matter.js, Planck.js, p2.js, ODE, Box2D.NET, and other physics libraries
- https://brm.io/matter-js/
Supports
- 2D physics engine for the web with broad, mid, and narrow phase detection, restitution, and sleeping
- https://piqnt.com/planck.js/
Supports
- 2D JavaScript physics engine for cross-platform HTML5 game development
- https://schteppe.github.io/p2.js/
Supports
- JavaScript 2D physics library, as listed in the awesome list
- https://github.com/ikpil/Box2D.NET
Supports
- A port of Box2D for .NET C#, Unity3D, and servers, as listed in the awesome list
- https://www.ode.org/
Supports
- Open source library for rigid body dynamics with integrated collision detection and friction
