Class CharacterComponent
- Namespace
- Stride.BepuPhysics
- Assembly
- Stride.BepuPhysics.dll
[ComponentCategory("Physics - Bepu")]
public class CharacterComponent : CharacterComponentAbstract, IIdentifiable, ISimulationUpdate, IComponent<ISimulationUpdate.SimUpdateProcessor, ISimulationUpdate>, IMarkedComponent
- Inheritance
-
objectCharacterComponent
- Implements
- Inherited Members
- Extension Methods
Constructors
CharacterComponent()
public CharacterComponent()
Properties
AirControlForceScale
Ratio of MaximumHorizontalForce to use when not on a supporting surface
[DataMemberRange(0, 1, 0.1, 0.25, 3)]
public float AirControlForceScale { get; set; }
Property Value
AirControlScale
Ratio of Speed to use when not on a supporting surface
[DataMemberRange(0, 1, 0.1, 0.25, 3)]
public float AirControlScale { get; set; }
Property Value
Contacts
Order is not guaranteed and may change at any moment
[Obsolete("Contacts are no longer collected, add your own ContactEventHandler")]
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
LocalUp
The direction local to Orientation used when jumping or finding a supporting surface
public Vector3 LocalUp { get; set; }
Property Value
MaximumHorizontalForce
Maximum force the character can apply to move along the supporting surface
public float MaximumHorizontalForce { get; set; }
Property Value
MaximumVerticalForce
Maximum force the character can apply to glue itself to the supporting surface
public float MaximumVerticalForce { get; set; }
Property Value
MinimumSupportContinuationDepth
Threshold under which the previous supporting surfaces' contact is still considered a support
public float MinimumSupportContinuationDepth { get; set; }
Property Value
MinimumSupportDepth
Threshold under which a contact is accepted as a support surface if the normal allows it
public float MinimumSupportDepth { get; set; }
Property Value
MoveVector
The current movement direction of this component, it is local to its Orientation
public Vector2 MoveVector { get; set; }
Property Value
Remarks
The input is scaled by Speed before usage
value does not have to be normalized;
if the vector passed in has a length of 2, the character will go twice as fast
NoContactResponse
[Obsolete("Contacts are no longer collected, add your own ContactEventHandler")]
protected bool NoContactResponse { get; }
Property Value
SlopeAngle
The maximum slope angle in degrees that the character can treat as a support
[DataMemberRange(1, 89, 1, 10, 1)]
public float SlopeAngle { get; set; }
Property Value
Speed
Base speed applied when moving, measured in units per second
public float Speed { get; set; }
Property Value
Velocity
[Obsolete("Use MoveVector instead")]
public Vector3 Velocity { get; set; }
Property Value
Methods
AfterSimulationUpdate(BepuSimulation, float, ref InternalCharacterData)
Called after the simulation updates
protected override void AfterSimulationUpdate(BepuSimulation sim, float simTimeStep, ref InternalCharacterData characterData)
Parameters
simBepuSimulationsimTimeStepfloatThe amount of time in seconds this simulation lasts for
characterDataInternalCharacterData
GroundTest(Vector3, float)
Returns whether this body is in contact with the ground.
[Obsolete("Contacts are no longer collected, add your own ContactEventHandler")]
protected bool GroundTest(Vector3 groundNormal, float threshold = 0)
Parameters
groundNormalVector3Which direction a surface has to be in to be considered as ground
thresholdfloatHow 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 matchesgroundNormalexactly.
Returns
Remarks
Goes through the list of Contacts to do so
Move(Vector3)
Sets the velocity based on direction and Speed
[Obsolete("Use MoveVector instead")]
public virtual void Move(Vector3 direction)
Parameters
directionVector3
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>(Contacts<TManifold>)
Fires the first time a pair is observed to be touching. Touching means that there are contacts with nonnegative depths in the manifold.
[Obsolete("Contacts are no longer collected, add your own ContactEventHandler")]
protected virtual void OnStartedTouching<TManifold>(Contacts<TManifold> contacts) where TManifold : unmanaged, IContactManifold<TManifold>
Parameters
contactsContacts<TManifold>Data associated with this contact event.
Type Parameters
TManifoldType of the contact manifold detected.
OnStoppedTouching<TManifold>(Contacts<TManifold>)
Fires when a pair stops touching. Touching means that there are contacts with nonnegative depths in the manifold.
[Obsolete("Contacts are no longer collected, add your own ContactEventHandler")]
protected virtual void OnStoppedTouching<TManifold>(Contacts<TManifold> contacts) where TManifold : unmanaged, IContactManifold<TManifold>
Parameters
contactsContacts<TManifold>Data associated with this contact event.
Type Parameters
TManifoldType of the contact manifold detected.
OnTouching<TManifold>(Contacts<TManifold>)
Fires whenever a pair is observed to be touching. Touching means that there are contacts with nonnegative depths in the manifold. Will not fire for sleeping pairs.
[Obsolete("Contacts are no longer collected, add your own ContactEventHandler")]
protected virtual void OnTouching<TManifold>(Contacts<TManifold> contacts) where TManifold : unmanaged, IContactManifold<TManifold>
Parameters
contactsContacts<TManifold>Data associated with this contact event.
Type Parameters
TManifoldType of the contact manifold detected.
SimulationUpdate(BepuSimulation, float, ref InternalCharacterData, in BodyReference, out bool)
Called before the simulation updates
protected override void SimulationUpdate(BepuSimulation sim, float simTimeStep, ref InternalCharacterData character, in BodyReference characterBody, out bool wakeupBody)
Parameters
simBepuSimulationsimTimeStepfloatThe amount of time in seconds this simulation lasts for
characterInternalCharacterDatacharacterBodyBodyReferencewakeupBodybool
TryJump()
Try to perform a jump on the next physics tick, will fail when not grounded
public virtual void TryJump()