Linear Velocity and Acceleration
The drone releases a crate while flying along the quay. The crate doesn't drop straight down: it keeps drifting forward as it falls faster and faster, tracing a curve toward the boat below. Two lines of code, run every physics step, draw that curve.
The rule
Acceleration nudges velocity; velocity nudges position; both times dt.
Linear velocity is how fast position changes, as a vector in m/s; its length is the speed. Acceleration is how fast velocity changes, in m/s². Near the ground, gravity gives every falling object the same acceleration, .
Each fixed physics step, the engine runs:
velocity += acceleration * dt
position += velocity * dtThis is semi-implicit Euler integration: update the velocity first, then move using the new velocity. It costs nothing more than doing it the other way round, and it stays stable for springs and orbits, where the "move first" version slowly gains energy until things fly apart.
Because vectors work one component at a time, the horizontal and vertical parts don't interfere with each other. With gravity pointing straight down, horizontal velocity never changes; only the vertical velocity grows.
Why step at all, when school physics has an exact formula for a falling object? Because in a game the forces keep changing: the player throttles up, the wind gusts, the crate clips a mast. Stepping handles any force the moment it appears, and with small, equal steps the result stays very close to the exact path.
The shortcut
Velocity first, then position, one component at a time. By hand, use a coarse step so the numbers stay readable (the game itself uses 0.02 s).
Step 1: velocity
(4, 0) + (0, −9.8) × 0.5 = (4, −4.9).
Two traps. Forgetting dt adds a per-second amount every step. And giving a released crate zero velocity is wrong: it inherits the drone's velocity at the moment of release, which is exactly why it drifts forward instead of dropping like a stone.
Drills
Answer fast — trust the rule.
The drone flies at (4, 0) m/s when it releases a crate. Ignoring air, what is the crate's horizontal velocity one second later?
What does semi-implicit Euler do each step?
A gull glides at velocity (−3, 4) m/s. What is its speed?
The gull's velocity stays at (−3, 4) m/s for 2 seconds. What is its acceleration?
Remember
- Each step: velocity += acceleration × dt, then position += velocity × dt.
- Components are independent: gravity changes only the vertical velocity.
- Traps: forgetting dt, and forgetting that a released object keeps its carrier's velocity.
