Physics · function
accelerateAlong
Explained in Your first game, Rigid bodies.
function accelerateAlong(state: PlanarState, wishX: number, wishZ: number, wishSpeed: number, accel: number, dt: number): numberimport { accelerateAlong } from '@driftengine/physics';Parameters
| Parameter | Type | Description |
|---|---|---|
state | PlanarState | |
wishX | number | Unit direction the body is asking to travel in. |
wishZ | number | |
wishSpeed | number | How fast it is asking to go, in that direction. |
accel | number | Metres per second squared this tick may deliver. |
dt | number |
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.