Log inGet started
Package

movement.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

statedWalk

How a body reads the walk its character's mover states, and which way that walk turns it. Locomotion and LocomotionFull both read it through here, and the engine running Locomotion's graph reads it by the same rule.

Each frame it moves a character, the CharacterController states its own walk across what it stands on (its motion less the carry of the ground under it) and the walk it was asked for (__poseProgram.stateWalk). A frame something else moves the character (a script, a path, a teleport) states none, and the body's motion that frame is its mover's velocity; a body with no mover of its own (an NPC body under the root its brain and navigation move) measures its motion in the world.

Exports

  • StatedWalk.motion(body, ms, cc, measured, dt) -> (vx, vy, vz, askedX?, askedZ?): this frame's motion across the frame body stands in: the stated walk whenever a mover states one, else the velocity of the entity's MovementState, else of its CharacterController, else the motion measured in the world (measure); the velocity along up; and the walk asked for, nil when nothing stated one.
  • StatedWalk.measured() -> Measured: a fresh record of a body's measured motion, which the component animating the body keeps.
  • StatedWalk.measure(body, measured, dt) -> (vx, vy, vz): the body's world position's step since the frame before over the frame's gameplay seconds, across its standing frame. A step faster than StatedWalk.TELEPORT_SPEED (150 m/s) is a placement and leaves the velocity as it was.
  • StatedWalk.read(body, hasOwnMover) -> (walkX, walkZ, askedX, askedZ)?: this frame's stated walk across the frame body stands in. A body with a mover of its own (a MovementState or a CharacterController on its entity) reads its entity's statement; one with none reads the nearest ancestor's. Nil when nothing states a walk for it.
  • StatedWalk.facing(vx, vz, askedX, askedZ, moveDeadzone) -> (dirX, dirZ)?: the direction a body turns toward: the walk asked for at any speed, else the velocity once it is faster than moveDeadzone. Nil when the body keeps its facing.
  • StatedWalk.moversChanged(body): tells the Locomotion and LocomotionFull on body that a MovementState or a CharacterController came to its entity or went from it, so each reads its movers again.