Table of Contents

Basic 2D Scene (Capsule) - Bullet Physics

The same first 2D scene as E01_2D_BasicScene, running on the legacy Bullet physics engine instead of Bepu. The scene code is character-for-character identical; the only difference is which toolkit package is referenced and which namespace is opened. That is the point of the example - physics is swapped at the project level, not by rewriting the scene.

The Program.cs file shows how to:

  • Running the base 2D scene on the legacy Bullet physics engine
  • Switching engine by namespace: Stride.CommunityToolkit.Bullet in place of .Bepu
  • Why the scene code needs no change when the physics engine does
  • Using helpers: SceneSetup2D, CreatePrimitive, CreateFlatMaterial

Basic 2D Scene (Capsule) - Bullet Physics

View on GitHub.

using Stride.CommunityToolkit.Bullet;
using Stride.CommunityToolkit.Engine;
using Stride.CommunityToolkit.Rendering.ProceduralModels;
using Stride.Core.Mathematics;
using Stride.Engine;

using var game = new Game();

game.Run(new SceneSetup2D().UseBullet(), start: Start);

void Start(Scene rootScene)
{
    var entity = game.CreatePrimitive(Primitive2D.Capsule(), new()
    {
        Material = game.CreateFlatMaterial(Color.White)
    });
    entity.Transform.Position = new Vector3(0, 8, 0);
    entity.Scene = rootScene;
}