public sealed class CharacterControllerA player or an NPC that walks: swept against the world, never solved, and in charge of its own velocity.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is Jolt's CharacterVirtual — a shape that is cast through the world every step and slid along whatever it hits. It has no body in the simulation, so nothing pushes it and it does not fall over, which is what a character wants and what a dynamic capsule famously does not give: a rigid body character sticks on seams, bounces down stairs and tips at the top of a ramp, and every game that has tried it has ended up here.
Gravity is the caller's. Velocity is whatever was last set, and Update moves by it. That is deliberate: a character's vertical motion is a gameplay decision — coyote time, variable jump height, a ladder — and a controller that applied gravity itself would have to be fought for every one of them. The pattern is to add gravity * dt before the update when airborne, and to zero it when grounded.
Characters are owned by their world and die with it. Disposing one early removes it from the world's list; disposing the world disposes any that are left.
Fields and properties (10)
public CharacterControllerSettings SettingsHow it was configured.
public bool IsDisposedWhether Dispose has been called.
public Vector3 PositionWhere the character is — the centre of its shape.
public Quaternion RotationWhich way it faces.
public Vector3 VelocityHow fast it is moving, in metres a second. Set this; Update acts on it.
public CharacterGround GroundWhat it is standing on, as of the last update.
public bool IsGroundedWhether it is on ground it can stand on.
public Vector3 GroundNormalThe normal of the ground under it, or up if there is none.
public Vector3 GroundVelocityHow fast the ground under it is moving — a lift, a moving platform.
public BodyHandle GroundBodyThe body it is standing on, if any.
Methods (5)
public void Update(float deltaTime)Moves the character by its velocity, sliding along whatever is in the way.
public Vector3 CancelVelocityTowardsSteepSlopes(Vector3 desired)Removes the component of a velocity that would push the character into a slope too steep to climb.
public bool TrySetShape(ShapeId shape, float maxPenetration = 0.01)Gives the character a different shape, if it fits where it is standing.
public void RefreshContacts()Re-tests the character's contacts without moving it.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Used by (5)
- CharacterControllerTestsVixen.Physics.Tests
- CharacterSceneTestsVixen.Physics.Tests
- PhysicsSceneVixen.Physics
- PhysicsWorldVixen.Physics
- PredictedPlayerMovementTestsVixen.Net.Physics.Tests