Table of Contents

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 Game

The Game instance to which the ground entity will be added.

entityName string

The 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 bool

If true, a CompoundCollider is added to the entity for physics interactions; otherwise no collider is created.

Returns

Entity

The newly created Entity representing the 3D ground plane.

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 IGame
type Primitive2DModelType
options Primitive2DCreationOptions

Returns

Entity

Create3DPrimitive(IGame, PrimitiveModelType, Primitive3DCreationOptions?)

public static Entity Create3DPrimitive(this IGame game, PrimitiveModelType type, Primitive3DCreationOptions? options = null)

Parameters

game IGame
type PrimitiveModelType
options Primitive3DCreationOptions

Returns

Entity

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 Game

The Game instance for which the base 3D scene will be set up.

Remarks

This method performs the following setup operations in sequence:

  1. Adds a default GraphicsCompositor to the game's SceneSystem and applies a clean UI stage.
  2. Adds a camera to the game and sets it up with a MouseLookCamera component.
  3. Adds a directional light to the game scene.
  4. Adds ground geometry to the game scene.