Table of Contents

Class CharacterComponent

Namespace
Stride.BepuPhysics
Assembly
Stride.BepuPhysics.dll
[ComponentCategory("Physics - Bepu")]
public class CharacterComponent : BodyComponent, IIdentifiable, ISimulationUpdate, IComponent<ISimulationUpdate.SimUpdateProcessor, ISimulationUpdate>, IMarkedComponent, IContactEventHandler
Inheritance
CharacterComponent
Implements
Inherited Members

Constructors

CharacterComponent()

public CharacterComponent()

Properties

Contacts

Order is not guaranteed and may change at any moment

public List<(CollidableComponent Source, Contact Contact)> Contacts { get; }

Property Value

List<(CollidableComponent Source, Contact Contact)>

IsGrounded

public bool IsGrounded { get; protected set; }

Property Value

bool

IsJumping

public bool IsJumping { get; }

Property Value

bool

JumpForce

Force of the impulse applied when calling TryJump()

[DataAlias("JumpSpeed")]
public float JumpForce { get; set; }

Property Value

float

NoContactResponse

protected bool NoContactResponse { get; }

Property Value

bool

Speed

Base speed applied when moving, measured in units per second

public float Speed { get; set; }

Property Value

float

Velocity

public Vector3 Velocity { get; set; }

Property Value

Vector3

Methods

AfterSimulationUpdate(BepuSimulation, float)

This is called internally right after the physics simulation does a tick

public virtual void AfterSimulationUpdate(BepuSimulation sim, float simTimeStep)

Parameters

sim BepuSimulation

The simulation this ISimulationUpdate is bound to, and the one currently updating

simTimeStep float

The amount of time in seconds since the last simulation

AttachInner(RigidPose, BodyInertia, TypedIndex)

Called every time this is added to a simulation

protected override void AttachInner(RigidPose pose, BodyInertia shapeInertia, TypedIndex shapeIndex)

Parameters

pose RigidPose
shapeInertia BodyInertia
shapeIndex TypedIndex

Remarks

May occur when certain larger changes are made to the object, Simulation is the one this object is being added to

GroundTest(Vector3, float)

Returns whether this body is in contact with the ground.

protected bool GroundTest(Vector3 groundNormal, float threshold = 0)

Parameters

groundNormal Vector3

Which direction a surface has to be in to be considered as ground

threshold float

How close to this direction a supporting contact has to be for it to be considered as ground. In the [-1,1] range, where -1 would return true for any given surface we are in contact with, 0 would return true for a surface that is at most 90 degrees away from groundNormal, and 1 would return true only when a surface matches groundNormal exactly.

Returns

bool

Remarks

Goes through the list of Contacts to do so

Move(Vector3)

Sets the velocity based on direction and Speed

public virtual void Move(Vector3 direction)

Parameters

direction Vector3

Remarks

direction does not have to be normalized; if the vector passed in has a length of 2, the character will go twice as fast

OnStartedTouching<TManifold>(CollidableComponent, CollidableComponent, ref TManifold, bool, int, BepuSimulation)

Fires the first time a pair is observed to be touching. Touching means that there are contacts with nonnegative depths in the manifold.

protected virtual void OnStartedTouching<TManifold>(CollidableComponent eventSource, CollidableComponent other, ref TManifold contactManifold, bool flippedManifold, int contactIndex, BepuSimulation bepuSimulation) where TManifold : unmanaged, IContactManifold<TManifold>

Parameters

eventSource CollidableComponent

Collidable that the event was attached to.

other CollidableComponent

Other collider eventSource collided with.

contactManifold TManifold

Set of remaining contacts in the collision.

flippedManifold bool

Whether the manifold's normals and offset is flipped from the source's point of view.

contactIndex int
bepuSimulation BepuSimulation

The simulation where the contact occured.

Type Parameters

TManifold

Type of the contact manifold detected.

OnStoppedTouching<TManifold>(CollidableComponent, CollidableComponent, ref TManifold, bool, int, BepuSimulation)

Fires when a pair stops touching. Touching means that there are contacts with nonnegative depths in the manifold.

protected virtual void OnStoppedTouching<TManifold>(CollidableComponent eventSource, CollidableComponent other, ref TManifold contactManifold, bool flippedManifold, int contactIndex, BepuSimulation bepuSimulation) where TManifold : unmanaged, IContactManifold<TManifold>

Parameters

eventSource CollidableComponent

Collidable that the event was attached to.

other CollidableComponent

Other collider eventSource collided with.

contactManifold TManifold

Set of remaining contacts in the collision.

flippedManifold bool

Whether the manifold's normals and offset is flipped from the source's point of view.

contactIndex int
bepuSimulation BepuSimulation

The simulation where the contact occured.

Type Parameters

TManifold

Type of the contact manifold detected.

SimulationUpdate(BepuSimulation, float)

This is called internally right before the physics simulation does a tick

public virtual void SimulationUpdate(BepuSimulation sim, float simTimeStep)

Parameters

sim BepuSimulation

The simulation this ISimulationUpdate is bound to, and the one currently updating

simTimeStep float

The amount of time in seconds since the last simulation

TryJump()

Try to perform a jump on the next physics tick, will fail when not grounded

public virtual void TryJump()