Physics · class

SweptStep

Explained in Your first game, Rigid bodies.

class SweptStep
import { SweptStep } from '@driftengine/physics';

Constructor

new

constructor(options?: SweptStepOptions)
ParameterTypeDescription
options?SweptStepOptions

Properties

NameTypeDescription
moveRefusedbooleanWhether the world refused a horizontal move this tick.
More

Read by anything that wants to tell a body that is stuck from one that is going in circles — StallEscape is the obvious consumer, and the two were written for each other.

sinceStepUpnumberSeconds since the last successful step up. See stepGraceSec.

Methods

beginTick

beginTick(dt: number): void

Open a tick: forget last tick's refusal and age the step-up grace.

ParameterTypeDescription
dtnumber
More

Both counters live here or they live in two places, which is exactly the bug this seam shipped with for one commit: the consumer kept its own sinceStepUp, advanced it, and the engine's stayed pinned at whatever the last step set — so the grace below never expired and a body perched on a rim was told, for ever, that it had just climbed onto a plateau.

slipOffContact

slipOffContact(body: Body, state: SweptState, dt: number, colliders: ColliderSet): boolean
ParameterTypeDescription
bodyBody
stateSweptState
dtnumber
collidersColliderSet

moveHorizontal

moveHorizontal(body: Body, state: SweptState, axis: Axis, want: number, colliders: ColliderSet, supported: boolean, world: WorldOpinion): void
ParameterTypeDescription
bodyBody
stateSweptState
axisAxis
wantnumber
collidersColliderSet
supportedboolean
worldWorldOpinion