Hazel

Your First Scene

In this tutorial you build a small scene from nothing: a ground, a few shapes, a sun and a camera. Then you paint one of the shapes, make it spin with a five-line script, and play it. It takes about fifteen minutes.

You need Renzora installed (Installation). For the script part you also need Rust; if it is missing, the editor offers to install it for you.

1. Make a project

  1. Start Renzora. You land on the Project Launcher.
  2. Click New Project.
  3. Make a new, empty folder somewhere you will find it again, for example Documents/my_first_game, and choose it.

The editor opens on your new project. The folder's name becomes the project's name, and you are looking at its first scene, called main. It is empty.

The editor on a new, empty scene

2. Lay the ground

An empty scene's Hierarchy shows a few quick ways to start. Under Common entities, click Plane.

A flat square appears in the middle of the viewport, already selected, and the Hierarchy now lists it as plane. It is only 2 metres across, so make it bigger:

  1. In the Inspector on the right, find Transform.
  2. Set Scale to 10 for X and 10 for Z. (Y does not matter for a flat plane.)

Now give it a better name. Right-click plane in the Hierarchy, choose Edit > Rename (or press F2), type ground and press Enter.

Names in Renzora are lowercase with underscores, like ground or red_cube. If you type capitals or spaces, the editor tidies them up for you.

3. Add some shapes

Open the Shapes tab in the bottom panel (press Ctrl+Space if the bottom panel is hidden). It is a library of ready-made shapes.

The shape library in the bottom panel

Drag a Cube from the library and drop it onto the ground in the viewport. It lands sitting on the surface where you let go. Do the same with a Sphere and a Cylinder, spread out a little.

(Clicking a shape instead of dragging it adds it at the centre of the world.)

To move a shape afterwards, click it in the viewport and drag the coloured arrows of its gizmo. W switches to the move tool, E to rotate, R to scale, and Ctrl+Z undoes a mistake.

A cube selected on the ground with the move gizmo's arrows

Getting around the viewport

  • Hold the right mouse button and move the mouse to look around.
  • While holding it, use W A S D to fly, and Q / E to go down and up.
  • Scroll to zoom in and out.
  • Select something and press F to bring it into view.

4. Add a camera

The viewport's view is only for editing. Your game needs a camera of its own to see through.

  1. Click Add Entity at the top of the Hierarchy. A search box opens with everything you can add, grouped into categories.
  2. Type camera and choose Camera 3D.
  3. It appears as camera_3d with a small star beside it: the star marks the camera your game starts with.
  4. Move the viewport until you like the view of your shapes.
  5. Right-click camera_3d in the Hierarchy and choose Camera > Snap to Viewport.

The camera jumps to exactly where you are looking from. That is the shot your game will open on.

5. Add a sun

Shapes need light. Click Add Entity again, type sun and choose Sun.

The Add Entity window, with Sun under Lighting

The scene is now lit by a mid-morning sun, with shadows. Select sun and look at the Inspector: Azimuth and Elevation set where it is in the sky, Color its tint, and Illuminance how bright it is. Leave them as they are for now. See Lighting for more.

6. Change a colour

Click the cube to select it. In the Inspector, find the Material section. Every new shape wears a grid pattern, tinted by its Base Color.

Click the Base Color swatch and pick a bright red. The cube changes as you drag through the colours.

Try it on the sphere and the cylinder too. (When you are ready for real surfaces, such as wood, metal or stone, see Materials.)

7. Make the cube spin

Behaviour comes from scripts. A script is a small piece of Rust code attached to something in the scene.

  1. Right-click cube in the Hierarchy and choose Attach > Rust Script.
  2. A Create Asset window opens. Change the Name to spin. Leave the destination as the scripts folder, and leave Attach to cube ticked.
  3. Click Create.

Renzora writes scripts/spin.rs, attaches it to the cube, and starts compiling it in the background. The first compile takes a little while; after that it takes about a second. The Console tab in the bottom panel shows a line saying the script compiled.

spin.rs in the Inspector's Scripts section

If Rust is not installed yet, a window asks to install it. Click Install and wait for it to finish.

What the script says

In the Assets tab, open the scripts folder and double-click spin.rs. It opens in the Code Editor:

use bevy::prelude::*;
use renzora::ScriptCtx;

fn update(ctx: &mut ScriptCtx) {
    let dt = ctx.delta();
    if let Some(mut transform) = ctx.get_mut::<Transform>() {
        transform.rotate_y(dt);
    }
}

renzora::script!(update);

(The real file also has a couple of comment lines, starting with //, that explain it.)

In plain words:

  • The two use lines at the top bring in the names the script needs.
  • fn update is a function Renzora calls once every frame while the game runs. ctx is the script's handle on the thing it is attached to, which here is the cube.
  • ctx.delta() is how many seconds passed since the last frame, a tiny number like 0.016. Using it makes the spin the same speed on a fast computer and a slow one.
  • ctx.get_mut::<Transform>() gets the cube's Transform: its position, rotation and scale, the same values you see in the Inspector.
  • transform.rotate_y(dt) turns the cube a little around its vertical axis. A little, every frame, adds up to a full turn about every six seconds.
  • The last line, renzora::script!(update), tells Renzora which function to call.

Make it faster: change rotate_y(dt) to rotate_y(dt * 3.0), then press Ctrl+S. The script recompiles on save.

8. Press Play

Click Play in the top-right corner, or press F5.

The editor saves your scene, waits for any script that is still compiling, and starts your game. It appears in the Game tab, seen through camera_3d, and the cube spins.

The game running, seen through the scene's camera

Your game runs as its own program, so nothing it does changes your scene. Click Stop (the same button) or press F5 again to end it.

Scripts only run while the game is playing, which is why the cube sits still in the viewport while you edit.

9. Save

Press Ctrl+S, or click the floppy disk in the top bar. The status bar at the bottom left says Saved.

Your scene is stored in your project folder as scenes/main.bsn. Next time you open the project from the launcher, it is all there, and its card shows a picture of it.

What you learned

  • A project is a folder. A scene is a level inside it.
  • Things in a scene are entities. You add them with the Hierarchy, the Shapes library, or Add Entity.
  • The Inspector changes an entity's settings, such as its size, colour or light.
  • The game sees through the camera with the star.
  • A Rust script runs every frame on the entity it is attached to, and recompiles when you save it.

What's next

  • Core Concepts puts names to what you just did.
  • Rust Scripts for what else a script can do.
  • Input to move things with the keyboard and gamepad.
  • Models to bring in your own art.
  • Exporting to turn it into a game you can share.