Friction Drag
Friction / Drag¶
function applyFriction(entity, frictionCoefficient, dt):
entity.velocity *= (1 - frictionCoefficient * dt)
// or, for stronger stopping:
// entity.velocity *= pow(frictionCoefficient, dt)
Friction/drag as velocity *= (1 - k*dt) is an exponential decay approximation — each frame, velocity loses a fraction of itself. True exponential decay uses velocity *= exp(-k*dt), which is more numerically stable at large dt, but the linear approximation is fine for most games.