Capsule with rigid body in Visual Basic
This code example demonstrates how to initialize a game, set up a basic 3D scene, add a skybox, create a 3D capsule entity, set its position, and add it to the scene using the extensions provided by the toolkit. The Create3DPrimitive() method, a part of the toolkit, automatically equips the capsule entity with a rigid body and a collider. This example serves as a simple starting point for building a game with Stride, leveraging the utilities provided by the toolkit to simplify common game development tasks.
Note
This example requires the additional NuGet packages Stride.CommunityToolkit.Bepu, Stride.CommunityToolkit.Skyboxes and Stride.CommunityToolkit.Windows. Make sure to install all before running the code.

View on GitHub.
Imports Stride.CommunityToolkit.Bepu
Imports Stride.CommunityToolkit.Engine
Imports Stride.CommunityToolkit.Rendering.ProceduralModels
Imports Stride.CommunityToolkit.Skyboxes
Imports Stride.Core.Mathematics
Imports Stride.Engine
Imports GameExtensions = Stride.CommunityToolkit.Engine.GameExtensions
Module Program
Private ReadOnly game As New Game()
Sub Main()
GameExtensions.Run(game, Nothing, AddressOf StartGame)
End Sub
Private Sub StartGame(rootScene As Scene)
game.SetupBase3DScene()
game.AddSkybox()
game.AddProfiler()
Dim entity = game.Create3DPrimitive(PrimitiveModelType.Capsule)
entity.Transform.Position = New Vector3(0, 8, 0)
entity.Scene = rootScene
End Sub
End Module
Private game As New Game()This line of code creates a new instance of theGameclass. The Game class is central to the Stride engine, managing the overall game loop, scenes, and updates to the entities.GameExtensions.Run(game, Nothing, AddressOf StartGame)This line initiates the game loop. TheRunmethod, fromGameExtensions, is responsible for starting the game and it takes a reference to theStartGamemethod as a parameter. This method is called once when the game starts. TheNothingargument here is for an optional parameter that is not being used in this case.game.SetupBase3DScene()This line sets up a basic 3D scene. It's a helper method provided to quickly set up a scene with a default camera, lighting.game.AddSkybox()This line adds a skybox to the scene. A skybox is a cube that surrounds the entire scene and is textured with an image to create the illusion of a sky.game.AddProfiler()This line adds a profiler to the game.Dim entity = game.Create3DPrimitive(PrimitiveModelType.Capsule)Here, a new entity is created in the form of a 3D capsule primitive. TheCreate3DPrimitivemethod is a helper method provided to create basic 3D shapes.entity.Transform.Position = New Vector3(0, 8, 0)This line sets the position of the created entity in the 3D space. ThePositionproperty of theTransformcomponent determines the location of the entity.entity.Scene = rootSceneFinally, the entity is added to therootScene. TheSceneproperty of an entity determines which scene it belongs to.