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
IsJumping
public bool IsJumping { get; }
Property Value
JumpForce
Force of the impulse applied when calling TryJump()
[DataAlias("JumpSpeed")]
public float JumpForce { get; set; }
Property Value
NoContactResponse
protected bool NoContactResponse { get; }
Property Value
Speed
Base speed applied when moving, measured in units per second
public float Speed { get; set; }
Property Value
Velocity
public Vector3 Velocity { get; set; }
Property Value
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
BepuSimulationThe simulation this ISimulationUpdate is bound to, and the one currently updating
simTimeStep
floatThe 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
RigidPoseshapeInertia
BodyInertiashapeIndex
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
Vector3Which direction a surface has to be in to be considered as ground
threshold
floatHow 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 matchesgroundNormal
exactly.
Returns
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
CollidableComponentCollidable that the event was attached to.
other
CollidableComponentOther collider
eventSource
collided with.contactManifold
TManifoldSet of remaining contacts in the collision.
flippedManifold
boolWhether the manifold's normals and offset is flipped from the source's point of view.
contactIndex
intbepuSimulation
BepuSimulationThe 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
CollidableComponentCollidable that the event was attached to.
other
CollidableComponentOther collider
eventSource
collided with.contactManifold
TManifoldSet of remaining contacts in the collision.
flippedManifold
boolWhether the manifold's normals and offset is flipped from the source's point of view.
contactIndex
intbepuSimulation
BepuSimulationThe 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
BepuSimulationThe simulation this ISimulationUpdate is bound to, and the one currently updating
simTimeStep
floatThe 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()