Your first project
This page makes a scene with a camera, a light and a cube, then spins the cube from C#. It takes about ten minutes. You need Orblit and the .NET 10 SDK from Installing.
1. Make the project
Section titled “1. Make the project”- Start the classic editor. The project manager opens.
- Choose Create.
- Type a Project Name, such as
Spinner. - Choose a Project Path in an empty folder.
- Leave the Renderer on Forward+.
- Choose Create. The editor opens on the new project.
2. Build the scene
Section titled “2. Build the scene”- In the Scene panel, under Create Root Node, choose 3D Scene. This
adds an Entity3D called
Entity3D. - With the root selected, choose Add Child Node. Search for
MeshInstance3Dand choose Create. - In the Inspector, set the Mesh property to New BoxMesh. A cube appears in the viewport.
- Select the root again and add a
Camera3D. In the Inspector, set its Position to0, 1, 4. - Add a
DirectionalLight3Dto the root. Set its Rotation to-45, 30, 0. - Press Ctrl+S, or Cmd+S on
macOS. Save the scene as
main.oscn.
3. Spin the cube
Section titled “3. Spin the cube”- Select the
MeshInstance3Dand choose Attach Script. - Set Language to C#, set Path to
res://Spinner.csand choose Create. The editor also makes the project’s.csprojthe first time. - Replace the file’s contents with this:
using Orblit;
public partial class Spinner : MeshInstance3D{ // Radians per second. [Export] public float Speed { get; set; } = 1.5f;
public override void OnStart() { Orb.Print("The cube is ready."); }
public override void OnFrame(double delta) { RotateY(Speed * (float)delta); }}The class name must match the file name. OnStart runs once, when the cube
joins the running scene. OnFrame runs every frame, and delta is the
seconds since the last one. [Export] shows Speed in the Inspector, so you
can change it there without touching the code.
4. Run it
Section titled “4. Run it”Press F5, or Cmd+B on macOS, or choose Run Project at the top right. The editor builds the C# first.
The first run asks for a main scene. Choose Select Current to use
main.oscn. A window opens with the cube turning, and the Output panel shows
The cube is ready.
- The cube turns at a steady rate.
- Change Speed in the Inspector and run again. The cube turns faster.
- If the build fails, run
dotnet --list-sdksand check for a line starting with10..
The class reference lists everything an entity can do. Start with Entity3D for 3D or Entity2D for 2D.
