moveAndSlide
Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
step |
PredictedStep |
entity |
PredictedEntity |
options |
MoveAndSlideOptions |
Returns
Section titled “Returns”Readonly<MoveAndSlideResult>
Example
Section titled “Example”const result = moveAndSlide(step, kart, { velocity, rotation: heading }); kart.velocity.copy(result.slideVelocity);Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Target extends Entity |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
step |
AuthoritativeStep |
entity |
BodyTarget<Target, Kinematic> |
options |
MoveAndSlideOptions |
Returns
Section titled “Returns”Readonly<MoveAndSlideResult>
Example
Section titled “Example”const result = moveAndSlide(step, kart, { velocity, rotation: heading }); kart.velocity.copy(result.slideVelocity);