Debug Shapes
This example sets up a basic 3D scene and adds debugging visuals. A special entity with a ShapeUpdater
component is added to update and render debug shapes in the scene, making it easier to visualize spatial information during development.
Note
This example requires the additional NuGet packages Stride.CommunityToolkit.Skyboxes
and Stride.CommunityToolkit.Bepu
. Make sure to install both before running the code.
View on GitHub.
using Example08_DebugShapes.Scripts;
using Stride.CommunityToolkit.Bullet;
using Stride.CommunityToolkit.DebugShapes.Code;
using Stride.CommunityToolkit.Engine;
using Stride.CommunityToolkit.Skyboxes;
using Stride.Engine;
using var game = new Game();
game.Run(start: Start);
void Start(Scene rootScene)
{
AddDebugComponent(rootScene);
SetupBaseScene();
}
void SetupBaseScene()
{
game.AddGraphicsCompositor();
game.Add3DCamera().Add3DCameraController();
game.AddDirectionalLight();
game.AddSkybox();
game.Add3DGround();
game.AddDebugShapes();
}
void AddDebugComponent(Scene scene)
{
var entity = new Entity("Debug Shapes")
{
new ShapeUpdater()
};
scene.Entities.Add(entity);
}