Class GameExtensions
- Namespace
- Stride.CommunityToolkit.Bepu
- Assembly
- Stride.CommunityToolkit.Bepu.dll
Provides extension methods for the Game class to simplify common game setup tasks for the Bepu Physics engine.
public static class GameExtensions
- Inheritance
-
GameExtensions
Methods
Add3DGround(Game, string?, Vector2?, bool)
Adds a 3D ground entity to the game with a default size of 15x15 units. The ground is created as a plane, and a collider can be optionally added.
public static Entity Add3DGround(this Game game, string? entityName = "Ground", Vector2? size = null, bool includeCollider = true)
Parameters
game
GameThe Game instance to which the ground entity will be added.
entityName
stringThe name to assign to the new ground entity. If
null
, DefaultGroundName is used.size
Vector2?The width and length of the ground plane as a Vector2. If
null
, Default3DGroundSize is used.includeCollider
boolIf
true
, a CompoundCollider is added to the entity for physics interactions; otherwise no collider is created.
Returns
Examples
// Add a 20×20 ground plane named "MyGround" with a collider
var ground = game.Add3DGround("MyGround", new Vector2(20, 20), includeCollider: true);
Create2DPrimitive(IGame, Primitive2DModelType, Primitive2DCreationOptions?)
public static Entity Create2DPrimitive(this IGame game, Primitive2DModelType type, Primitive2DCreationOptions? options = null)
Parameters
game
IGametype
Primitive2DModelTypeoptions
Primitive2DCreationOptions
Returns
Create3DPrimitive(IGame, PrimitiveModelType, Primitive3DCreationOptions?)
public static Entity Create3DPrimitive(this IGame game, PrimitiveModelType type, Primitive3DCreationOptions? options = null)
Parameters
game
IGametype
PrimitiveModelTypeoptions
Primitive3DCreationOptions
Returns
SetupBase2DScene(Game)
public static void SetupBase2DScene(this Game game)
Parameters
game
Game
SetupBase3DScene(Game)
Sets up a default 3D scene for the game, similar to creating an empty project through the editor.
public static void SetupBase3DScene(this Game game)
Parameters
game
GameThe Game instance for which the base 3D scene will be set up.
Remarks
This method performs the following setup operations in sequence:
- Adds a default GraphicsCompositor to the game's SceneSystem and applies a clean UI stage.
- Adds a camera to the game and sets it up with a MouseLookCamera component.
- Adds a directional light to the game scene.
- Adds ground geometry to the game scene.