Create Project
Command line and Visual Studio Code
The steps below show how to create a new Stride project using the command line. If you prefer Visual Studio Code, run the same commands from its integrated terminal.
Note
These instructions target Windows. While code-only projects can be built and run on Linux, the setup is currently more involved. We're working to simplify it and will provide official guidance later.
- Prerequisites: Make sure all prerequisites are installed. See Getting started for details.
- Create a console app. You can follow the official Microsoft tutorial or run:
dotnet new console --framework net8.0 --name YourProjectName
- Add the core toolkit package:
dotnet add package Stride.CommunityToolkit.Windows --prerelease
- Add the Bepu physics package:
dotnet add package Stride.CommunityToolkit.Bepu --prerelease
- Update Program.cs: Paste the example code below into your Program.cs file.
- Build (optional):
dotnet run
performs an implicit build, but you can build explicitly:dotnet build
- Run the project:
dotnet run
- Enjoy Stride: If everything is set up correctly, your project should run.
Visual Studio 2022 and JetBrains Rider
- Create a C# Console Application targeting .NET 8.
- Add the
Stride.CommunityToolkit.Windows
NuGet package (pre-release). This pulls in the required Stride packages. - Add the
Stride.CommunityToolkit.Bepu
package (pre-release) to include the Bepu physics integration. - Update Program.cs: Paste the example code below.
- Run the project using your IDE.
Example code
The example demonstrates basic usage of the Stride Game Engine in a code-only app.
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(start: Start);
void Start(Scene rootScene)
{
game.SetupBase3DScene();
var entity = game.Create3DPrimitive(PrimitiveModelType.Capsule);
entity.Transform.Position = new Vector3(0, 8, 0);
entity.Scene = rootScene;
}
using var game = new Game();
creates a newGame
instance.game.Run(start: Start);
starts the game and callsStart
when the game begins.void Start(Scene rootScene)
is invoked on start with the active root scene.game.SetupBase3DScene();
creates a basic 3D scene (camera, lighting, ground).game.Create3DPrimitive(PrimitiveModelType.Capsule)
creates a capsule primitive.entity.Transform.Position = new Vector3(0, 8, 0);
places the capsule 8 units above the ground.entity.Scene = rootScene;
adds the entity to the scene so it is rendered and simulated. This step is crucial because assigning the entity to the scene ensures it is rendered and visible in the game. Without this assignment, the entity would not be part of the scene graph, and therefore, it would not appear in the game.
Create3DPrimitive()
creates a capsule with rigid body physics. Because it starts above the ground, it will fall due to gravity.
Tip
Remove entities you no longer need to free resources and avoid unnecessary physics updates.
Additional examples
Browse more examples in the navigation on the left, grouped by language and complexity.
Select any example to see a short description and code snippets.