Table of Contents

Class GameExtensions

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

Extension methods on Game for a scene with Bepu physics. The scene itself is set up through UseBepu<T>(T) on a SceneSetup; the core's CreatePrimitive, Add3DGround and Add2DGround then attach Bepu bodies and colliders.

public static class GameExtensions
Inheritance
GameExtensions

Methods

AddGrabber(IGame)

Puts a GrabberScript on the camera entity, so the left mouse button picks up any dynamic body, carries it on the end of the camera ray and throws it on release.

public static GrabberScript AddGrabber(this IGame game)

Parameters

game IGame

The game whose camera entity gets the grabber.

Returns

GrabberScript

The grabber, for tuning its reach, force and keys.

Remarks

The script is also a Game Studio component, under Physics, for a project that would rather place it on the camera entity in the editor.

AddPhysicsDebug(IGame, Color4?, bool, bool, bool)

Adds Bepu's two debug views to the root scene on one entity: the collidable gizmos, toggled with P, and the physics debug meshes, toggled with F11, with the solver's contact points and normals when asked.

public static Entity AddPhysicsDebug(this IGame game, Color4? gizmoColor = null, bool gizmosVisible = false, bool meshesVisible = false, bool contactsVisible = false)

Parameters

game IGame

The game whose root scene gets the entity.

gizmoColor Color4?

An emissive colour for the gizmos, or null for the gizmo material's own.

gizmosVisible bool

Whether the gizmos are shown from the first frame.

meshesVisible bool

Whether the debug meshes are shown from the first frame.

contactsVisible bool

Whether the debug meshes include the solver's contact points and normals (Stride 4.4.1).

Returns

Entity

The entity, named Physics Debug, carrying a CollidableGizmoScript and a DebugRenderComponentScript.

Remarks

Both scripts act on the whole scene: the gizmo script draws every collider it finds, and one DebugRenderComponent turns the debug meshes on for every Bepu entity. One entity is all a scene needs; a second copy of either script answers the same key and toggles the first one back.