Distinguish collision detection from collision response.
Apply acceleration and damping predictably.
Keep physics rules independent from rendering.
Collision detection answers “are these shapes intersecting?” Response answers “what changes now?” A simple axis-aligned response can move an object back to the surface, remove velocity into the surface, and preserve tangential velocity.
Use one consistent coordinate convention. Decide whether positive y points down or up, and document it. A small simulation step is easier to reason about than a renderer that silently changes positions.
Exercises
Implement floor collision and grounded detection.
Add horizontal friction that approaches zero without reversing direction.
List edge cases for a player starting inside a wall.
Self-check
What is the difference between detection and response?
Why set position back to the surface?
What does damping represent?
Self-Check Quiz
1. What should happen to downward velocity after landing on a floor?
AnswerRemove the downward component, commonly by setting vertical velocity to zero, and mark the object grounded.
2. Why document the positive y direction?
AnswerGravity, jump, and collision signs depend on the coordinate convention; documenting it prevents inverted or inconsistent rules.
Homework
Build a small physics sandbox with gravity, floor collision, and jumping.
Record three input traces and expected positions at each update.
Explain how your system handles a large delta time.
Sample answerUse velocity += acceleration * delta, then position += velocity * delta. If the player crosses the floor, clamp position to the floor, clear downward velocity, and set grounded. Cap delta time or use fixed substeps after a pause.