Character
Beginner Designer
Characters are used for player and NPC movement. Entities with character components can be moved with Move, TryJump, and teleported by setting its Position property.
Add a Character Component to an Entity
In the Scene Editor, select the entity you want to add the component to.
In the Property Grid, click
Add component
, hoverPhysics - Bepu
and selectCharacterComponent
.
Note
You will need to set a collider for this newly created character, you can do so through the Collider property. The capsule shape is appropriate for most character colliders. For more information, see collider shapes.
Warning
Never use mesh colliders for characters, use them only for statics, they are far too slow to be used as characters. If you absolutely need a more complex shape than the primitive ones, use a convex hull instead, see collider shapes.
Have a look at the API for more detail on the properties of this component.
Custom Character Controllers
When creating a controller, it is recommended to create a new class inheriting from this component instead of using it as is, you can access its internal state and override it with your own logic to better fit your game.
using Stride.BepuPhysics;
using Stride.Core.Mathematics;
public class MyCharacterController : CharacterComponent
{
public override void Move(Vector3 direction)
{
base.Move(direction);
}
public override void TryJump()
{
base.TryJump();
}
public override void SimulationUpdate(BepuSimulation sim, float simTimeStep)
{
base.SimulationUpdate(sim, simTimeStep);
}
public override void AfterSimulationUpdate(BepuSimulation sim, float simTimeStep)
{
base.AfterSimulationUpdate(sim, simTimeStep);
}
}