Table of Contents

Capsule with rigid body in F#

The first code-only scene written in F#. What the C# version does - base scene, skybox, one capsule - plus a profiler, with the differences F# forces you to be explicit about: helpers that return a value must be piped to ignore, assignment to a mutable property uses the left arrow, and the game loop is started from a real main function marked with EntryPoint.

The Program.fs file shows how to:

  • Writing a code-only Stride app in F#
  • Discarding unwanted return values with |> ignore
  • Assigning to engine properties with the <- operator
  • Starting the loop from an [] main function
  • Passing the start callback by name: game.Run(start = Start)
  • Using helpers: SceneSetup3D, UseBepu, UseSkybox, AddProfiler, CreatePrimitive

Capsule with rigid body in F#

View on GitHub.

open Stride.CommunityToolkit.Bepu
open Stride.CommunityToolkit.Engine
open Stride.CommunityToolkit.Skyboxes
open Stride.CommunityToolkit.Rendering.ProceduralModels
open Stride.Core.Mathematics
open Stride.Engine

let game = new Game()

let Start rootScene =
    game.AddProfiler() |> ignore

    let capsule = game.CreatePrimitive(Primitive3D.Capsule(), BepuPhysicsOptions())
    capsule.Transform.Position <- new Vector3(0f, 2.5f, 0f)
    capsule.Scene <- rootScene

[<EntryPoint>]
let main argv =
    game.Run(SceneSetup3D().UseBepu().UseSkybox(), start = Start)
    0