Table of Contents

Class EntityExtensions

Namespace
Stride.CommunityToolkit.Bepu
Assembly
Stride.CommunityToolkit.Bepu.dll

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

entity Entity

The entity the body is added to.

shape Primitive2D

The flat shape the entity's model was built from; the collider is derived from it.

options BepuPhysicsOptions

The body's mode, component, mass and interpolation; null is a dynamic, interpolated body.

Returns

Entity

The entity, with the component added unless the mode is None.

Exceptions

ArgumentNullException

Thrown when entity or shape is 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

entity Entity

The entity the body is added to.

shape Primitive3D

The shape the entity's model was built from; the collider is derived from it.

options BepuPhysicsOptions

The body's mode, component, mass and interpolation; null is a dynamic, interpolated body.

Returns

Entity

The entity, with the component added unless the mode is None.

Exceptions

ArgumentNullException

Thrown when entity or shape is 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

shape Primitive2D

The 2D shape.

depth float

The 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 shape is null.

ColliderFor(Primitive3D)

The Bepu collider that matches shape.

public static ColliderBase ColliderFor(Primitive3D shape)

Parameters

shape Primitive3D

The 3D shape.

Returns

ColliderBase

A collider the same size as the shape's model, to put into a CompoundCollider.

Exceptions

ArgumentNullException

Thrown when shape is null.