Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

moveAndSlide

moveAndSlide(step, entity, options): Readonly<MoveAndSlideResult>

Moves entity, a kinematic body, by velocity for one tick: it first pushes the shape out of anything fixed or kinematic it overlaps, then sweeps the move, keeping each surface it meets as a plane and sliding along every plane met so far, along one a slide, along two their crease, against three a stop, at most maxSlides sweeps; then turns to rotation in place and is pushed out of what the turned shape overlaps; then, with floorSnapDistance, snaps down onto a floor. The body is placed at once, so a later mover this tick meets it where it stands, and on the room the physics step moves it the same way with the move’s velocity, so the solver pushes the dynamic bodies it meets along the tick’s chord. A dynamic body is never an obstacle. Several calls in one tick each sweep from where the last ended. In a predicted system the entity is the PredictedEntity the step handed out; on the room’s step any kinematic body. As Godot’s move_and_slide(), with the velocity passed and a result returned rather than a property read and written.

Parameter Type
step PredictedStep
entity PredictedEntity
options MoveAndSlideOptions

Readonly<MoveAndSlideResult>

const result = moveAndSlide(step, kart, { velocity, rotation: heading });
kart.velocity.copy(result.slideVelocity);

moveAndSlide<Target>(step, entity, options): Readonly<MoveAndSlideResult>

Moves entity, a kinematic body, by velocity for one tick: it first pushes the shape out of anything fixed or kinematic it overlaps, then sweeps the move, keeping each surface it meets as a plane and sliding along every plane met so far, along one a slide, along two their crease, against three a stop, at most maxSlides sweeps; then turns to rotation in place and is pushed out of what the turned shape overlaps; then, with floorSnapDistance, snaps down onto a floor. The body is placed at once, so a later mover this tick meets it where it stands, and on the room the physics step moves it the same way with the move’s velocity, so the solver pushes the dynamic bodies it meets along the tick’s chord. A dynamic body is never an obstacle. Several calls in one tick each sweep from where the last ended. In a predicted system the entity is the PredictedEntity the step handed out; on the room’s step any kinematic body. As Godot’s move_and_slide(), with the velocity passed and a result returned rather than a property read and written.

Type Parameter
Target extends Entity
Parameter Type
step AuthoritativeStep
entity BodyTarget<Target, Kinematic>
options MoveAndSlideOptions

Readonly<MoveAndSlideResult>

const result = moveAndSlide(step, kart, { velocity, rotation: heading });
kart.velocity.copy(result.slideVelocity);