Table of Contents

Basic 2D Scene (Capsule)

Create a minimal 2D scene using toolkit helpers and place a single capsule primitive with a flat material. Demonstrates primitive creation, basic positioning, and attaching the entity to the scene.

The Program.cs file shows how to:

  • Creating a 2D primitive with CreatePrimitive
  • Applying a flat material with CreateFlatMaterial
  • Positioning an entity with Transform.Position
  • Adding entities to a Scene (rootScene)
  • Using helpers: SceneSetup2D

Basic 2D Scene (Capsule)

View on GitHub.

using Stride.CommunityToolkit.Bepu;
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().UseBepu(), 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;
}