Class BodyComponent
- Namespace
- Stride.BepuPhysics
- Assembly
- Stride.BepuPhysics.dll
[ComponentCategory("Physics - Bepu")]
public class BodyComponent : CollidableComponent, IIdentifiable
- Inheritance
-
BodyComponent
- Implements
- Derived
- Inherited Members
Properties
AngularVelocity
The rotation velocity in unit per second
public Vector3 AngularVelocity { get; set; }
Property Value
Remarks
The rotation format is in axis-angle, meaning that AngularVelocity.Normalized is the axis of rotation, while AngularVelocity.Length is the amount of rotation around that axis in radians per second
Awake
Whether the body is being actively simulated. Setting this to true will attempt to wake the body; setting it to false will force the body and any constraint-connected bodies asleep.
public bool Awake { get; set; }
Property Value
BodyInertia
The mass and inertia tensor of this body
public BodyInertia BodyInertia { get; set; }
Property Value
- BodyInertia
CollidableReference
protected override CollidableReference? CollidableReference { get; }
Property Value
- CollidableReference?
Constraints
The constraints targeting this body, some of those may not be Attached
public IReadOnlyList<ConstraintComponentBase> Constraints { get; }
Property Value
ContinuousDetection
Determines the continuous collision detection configuration set for that object. Helps prevent fast-moving objects from tunneling through other objects.
public ContinuousDetection ContinuousDetection { get; set; }
Property Value
- ContinuousDetection
ContinuousDetectionMode
Whether the object's path or only its destination is checked for collision when moving, prevents objects from passing through each other at higher speed
public ContinuousDetectionMode ContinuousDetectionMode { get; set; }
Property Value
- ContinuousDetectionMode
Remarks
This property is a shortcut to the ContinuousDetection.BepuPhysics.Collidables.ContinuousDetection.Mode property
Gravity
Whether gravity should affect the simulation's PoseGravity
public bool Gravity { get; set; }
Property Value
Remarks
Gravity is always active if UsePerBodyAttributes is false
InterpolationMode
Controls whether and how the motion of this body is smoothed out between physics update
public InterpolationMode InterpolationMode { get; set; }
Property Value
Kinematic
When kinematic is set, the object will not be affected by physics forces like gravity or collisions but will still push away bodies it collides with.
public bool Kinematic { get; set; }
Property Value
LinearVelocity
The translation velocity in unit per second
public Vector3 LinearVelocity { get; set; }
Property Value
MaterialProperties
protected override ref MaterialProperties MaterialProperties { get; }
Property Value
MinimumTimestepCountUnderThreshold
The number of time steps that the body must be under the sleep threshold before the body becomes a sleeping candidate. Note that the body is not guaranteed to go to sleep immediately after meeting this minimum.
public byte MinimumTimestepCountUnderThreshold { get; set; }
Property Value
Orientation
The rotation of this body in the physics scene, setting it will 'teleport' this object's rotation to the one provided.
public Quaternion Orientation { get; set; }
Property Value
Remarks
Using this property to move objects around is not recommended, as it disregards any collider that may overlap with the body at this new orientation, you should make sure the area is clear to ensure this object does not become stuck in the scenery.
Pose
protected override RigidPose? Pose { get; }
Property Value
- RigidPose?
Position
The position of this body in the physics scene, setting it will teleport this object to the positoin provided.
public Vector3 Position { get; set; }
Property Value
Remarks
Using this property to move objects around is not recommended, as it disregards any collider that may overlap with the body at this new position, you should make sure the area is clear to ensure this object does not become stuck in the scenery.
SleepThreshold
Threshold of squared combined velocity under which the body is allowed to go to sleep. Setting this to a negative value guarantees the body cannot go to sleep without user action.
public float SleepThreshold { get; set; }
Property Value
SpeculativeMargin
Automatically computed size of the margin around the surface of the shape in which contacts can be generated. These contacts will have negative depth and only contribute if the frame's velocities would push the shapes of a pair into overlap.
This is automatically set by bounding box prediction each frame, and is bound by the collidable's BepuPhysics.Collidables.Collidable.MinimumSpeculativeMargin and BepuPhysics.Collidables.Collidable.MaximumSpeculativeMargin values. The effective speculative margin for a collision pair can also be modified from INarrowPhaseCallbacks callbacks.
This should be positive to avoid jittering.
It can also be used as a form of continuous collision detection, but excessively high values combined with fast motion may result in visible 'ghost collision' artifacts. For continuous collision detection with less chance of ghost collisions, use BepuPhysics.Collidables.ContinuousDetectionMode.Continuous.
If using BepuPhysics.Collidables.ContinuousDetectionMode.Continuous, consider setting BepuPhysics.Collidables.Collidable.MaximumSpeculativeMargin to a smaller value to help filter ghost collisions.
For more information, see the Continuous Collision Detection documentation.
public float SpeculativeMargin { get; set; }
Property Value
Methods
ApplyAngularImpulse(Vector3)
Applies an explosive force which will only affect this body's angular velocity
public void ApplyAngularImpulse(Vector3 impulse)
Parameters
impulse
Vector3
Remarks
Does not wake the body up
ApplyImpulse(Vector3, Vector3)
Applies an explosive force at a specific offset off of this body which will affect both its angular and linear velocity
public void ApplyImpulse(Vector3 impulse, Vector3 impulseOffset)
Parameters
impulse
Vector3Impulse to apply to the velocity
impulseOffset
Vector3World space offset from the center of the body to apply the impulse at
Remarks
Does not wake the body up
ApplyLinearImpulse(Vector3)
Applies an explosive force which will only affect this body's linear velocity
public void ApplyLinearImpulse(Vector3 impulse)
Parameters
impulse
Vector3
Remarks
Does not wake the body up
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
DetachInner()
Called every time this is removed from the simulation
protected override void DetachInner()
Remarks
May occur right before AttachInner(RigidPose, BodyInertia, TypedIndex) when certain larger changes are made to the object, Simulation is the one this object was on prior to detaching
GetHandleValue()
protected override int GetHandleValue()