Class GameExtensions
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
gameIGameThe 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
gameIGameThe game whose root scene gets the entity.
gizmoColorColor4?An emissive colour for the gizmos, or null for the gizmo material's own.
gizmosVisibleboolWhether the gizmos are shown from the first frame.
meshesVisibleboolWhether the debug meshes are shown from the first frame.
contactsVisibleboolWhether 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.