Quick Start: Build Your First Playable Scene

This tutorial sets up a simple third-person playable scene with:

  • camera-relative movement (WASD)
  • jump (SPACE)
  • physics collision against the ground

Your game setup lives in game_logic/Game.cs inside Game.Setup(World world).

1. Open Game.cs

using System;
using ECS;

public static class Game
{
    public static void Setup(World world)
    {
        // Scene setup goes here
    }
}

2. Create a Player

Spawn a blue capsule mesh and add movement, camera, collider, and rigidbody components:

        PhysicsWorld.Instance.Init();

        int playerMesh = NativeBridge.CreateCapsuleMesh(0.3f, 1.2f, 32, 16, new Color(0.2f, 0.4f, 1.0f));
        int player = world.SpawnMeshEntity(playerMesh, new Transform { Position = new Vec3(0f, 1.2f, 0f) });

        world.AddComponent(player, new Movable { Speed = GameConstants.PlayerMoveSpeed });
        world.AddComponent(player, new Camera { Offset = new Vec3(0f, 0f, 3f), Fov = 45f });
        world.AddComponent(player, new Collider {
            Shape = ShapeType.Capsule,
            CapsuleHalfHeight = 0.6f,
            CapsuleRadius = 0.3f
        });
        world.AddComponent(player, new Rigidbody {
            MotionType = JPH_MotionType.Dynamic,
            Friction = 0.8f,
            GravityFactor = 1.0f,
            LockRotation = true
        });

3. Add Ground + Light

        int groundMesh = NativeBridge.CreatePlaneMesh(25f, 25f, new Color(0.3f, 0.3f, 0.3f));
        world.SpawnMeshEntity(groundMesh, new Transform { Position = new Vec3(0f, -1f, 0f) });

        world.Spawn(
            new Transform { Position = new Vec3(0f, -1f, 0f) },
            new Rigidbody { MotionType = JPH_MotionType.Static, Friction = 0.8f },
            new Collider { Shape = ShapeType.Plane, PlaneHalfExtent = 100f }
        );

        world.Spawn(
            new Transform(),
            new Light {
                Type = LightType.Directional,
                Direction = new Vec3(-1f, -0.5f, -0.5f),
                Intensity = 1f,
                CastShadow = true
            }
        );

4. Register Systems

System order matters. Keep physics before camera/render sync:

        world.AddSystem(Systems.InputMovementSystem);
        world.AddSystem(Systems.TimerSystem);
        world.AddSystem(Systems.PhysicsSystem);
        world.AddSystem(Systems.CameraFollowSystem);
        world.AddSystem(Systems.LightSyncSystem);
        world.AddSystem(Systems.HierarchyTransformSystem);
        world.AddSystem(Systems.DebugOverlaySystem);
        world.AddSystem(Systems.DebugColliderRenderSystem);
        world.AddSystem(Systems.RenderSyncSystem); // always last

5. Build and Run

make run

Controls

KeyAction
W / A / S / DMove player (camera-relative)
SPACEJump
Mouse (when locked)Orbit camera yaw/pitch
ESCToggle cursor lock
Q / ECamera yaw
R / FCamera pitch
TABToggle first-person / third-person
Scroll wheelZoom in/out (third-person)
F3Toggle debug overlay + collider wires

Next Steps