Physics · function

accelerateAlong

Explained in Your first game, Rigid bodies.

function accelerateAlong(state: PlanarState, wishX: number, wishZ: number, wishSpeed: number, accel: number, dt: number): number
import { accelerateAlong } from '@driftengine/physics';

Parameters

ParameterTypeDescription
statePlanarState
wishXnumberUnit direction the body is asking to travel in.
wishZnumber
wishSpeednumberHow fast it is asking to go, in that direction.
accelnumberMetres per second squared this tick may deliver.
dtnumber

Returns How much speed was actually added, so a consumer can tell a stalled motor from a satisfied one — a demand the ground refuses is exactly the interesting case for anything drawing wheelspin or smoke.