public static class CharacterMotionTurns a character's intent into the velocity its controller is asked to move by.
Remarks
A pure function, and that is the requirement rather than the style. Everything it reads is an argument and everything it changes is the state it is handed; it touches no clock, no random source and no field of its own. That is what [16](../../../docs/plan/16-networking.md)'s PredictedStep demands — the same tick is simulated twice whenever a snapshot disagrees, and a step that is not reproducible does not merely predict badly, it makes the correction itself wrong. It is also why this is a static class beside the bridge rather than a method on it: a rule that cannot reach a field cannot accidentally depend on one.
It knows nothing about Jolt. The sweep, the stairs and the slope cancellation are the CharacterController's; this decides only what the character is trying to do. So every rule below is testable with no native library, on any runner, which is what makes the determinism assertion cheap enough to run everywhere.
Methods (4)
public static void Step(in CharacterMovement settings, ref CharacterState state, in MoveIntent intent, CharacterGround ground, float deltaTime)Advances one character's motion by one fixed step.
public static Vector3 WantedVelocity(in CharacterMovement settings, in CharacterState state, in MoveIntent intent)How fast the character is asking to go, in world space.
public static float TopSpeed(in CharacterMovement settings, in CharacterState state, in MoveIntent intent)The top speed the character's current state and intent allow.
public static Vector3 MoveTowards(Vector3 from, Vector3 to, float maximum)Moves one vector towards another by at most a fixed distance.
Used by (3)
- CharacterAllocationTestsVixen.Physics.Tests
- CharacterMotionTestsVixen.Physics.Tests
- PhysicsSceneVixen.Physics