Class EntityExtensions
Extension methods on Entity that add Bepu 2D and 3D physics with the collider that matches a primitive shape, plus the collider derivation itself, ColliderFor(Primitive3D) and ColliderFor(Primitive2D, float), for callers who build their own body.
public static class EntityExtensions
- Inheritance
-
EntityExtensions
Methods
AddBepuPhysics(Entity, Primitive2D, BepuPhysicsOptions?)
Adds Bepu 2D physics to the entity, with the collider that matches shape, extruded
by the shape's depth.
public static Entity AddBepuPhysics(this Entity entity, Primitive2D shape, BepuPhysicsOptions? options = null)
Parameters
entityEntityThe entity the body is added to.
shapePrimitive2DThe flat shape the entity's model was built from; the collider is derived from it.
optionsBepuPhysicsOptionsThe body's mode, component, mass and interpolation; null is a dynamic, interpolated body.
Returns
Exceptions
- ArgumentNullException
Thrown when
entityorshapeis null.- InvalidOperationException
A component is supplied together with None.
AddBepuPhysics(Entity, Primitive3D, BepuPhysicsOptions?)
Adds Bepu 3D physics to the entity, with the collider that matches shape.
public static Entity AddBepuPhysics(this Entity entity, Primitive3D shape, BepuPhysicsOptions? options = null)
Parameters
entityEntityThe entity the body is added to.
shapePrimitive3DThe shape the entity's model was built from; the collider is derived from it.
optionsBepuPhysicsOptionsThe body's mode, component, mass and interpolation; null is a dynamic, interpolated body.
Returns
Exceptions
- ArgumentNullException
Thrown when
entityorshapeis null.- InvalidOperationException
A component is supplied together with None.
ColliderFor(Primitive2D, float)
The Bepu collider that matches a flat shape, extruded depth along Z.
public static ColliderBase ColliderFor(Primitive2D shape, float depth)
Parameters
shapePrimitive2DThe 2D shape.
depthfloatThe thickness of the collider along Z.
Returns
- ColliderBase
A collider the same size as the shape's model, to put into a CompoundCollider.
Exceptions
- ArgumentNullException
Thrown when
shapeis null.
ColliderFor(Primitive3D)
The Bepu collider that matches shape.
public static ColliderBase ColliderFor(Primitive3D shape)
Parameters
shapePrimitive3DThe 3D shape.
Returns
- ColliderBase
A collider the same size as the shape's model, to put into a CompoundCollider.
Exceptions
- ArgumentNullException
Thrown when
shapeis null.