Hazel

Animating

This page covers making things move over time: playing the animations a model came with, and keying your own on the Timeline. A character, a door, a light that flickers, a camera that sweeps across the level: they all work the same way.

Clips and the Animator

An animation is stored in a clip, a .anim file in your project. A clip can hold two kinds of tracks, side by side:

  • Bone tracks move the skeleton of a rigged model: a walk, a jump, a wave.
  • Property tracks change any number on any component: a light's intensity, a camera's position, a door's rotation, a sprite's frame. They need no skeleton, so you can animate a plain cube.

To play clips, an entity needs an Animator component. The Animator keeps a list of the clips it can play, each under a short slot name such as idle or walk. Scripts, state machines and the editor all refer to a clip by that name, never by its file path, so you can swap the file behind a name without touching anything else.

The Animator in the Inspector

Select the model and look for Animator in the Inspector.

PartWhat it does
Clip cardsOne card per clip: a play button, the name (click to rename), Speed (1 is normal speed, from 0.05 to 5), a loop toggle, and remove
Drop areaDrag .anim files from the Assets panel here to add them as clips. A multi-selection adds every clip in it
Default clipThe clip that starts playing when the game starts
Blend timeHow long, in seconds, one clip takes to fade into the next
State machineAn optional .animsm file that picks the clip for you. See The Animator

Getting clips into a project

From a model file

When you import an animated model (.glb, .gltf, .fbx, .usd and friends), each animation inside it is written to the project as its own .anim file. A .bvh file is animation only, with no mesh. Blend shape (morph target) animation comes in too, as its own tracks.

Drop the model into the scene and its clips are found and added to an Animator for you. If you placed a model before its animations finished importing, select it and press Scan for clips in the Animation panel to look again.

See Models for importing.

Animation-only files

Many character packs ship one mesh plus a folder of separate animation files. Put the animation files beside the character and import them: the engine records the skeleton each clip was made on (a .skel file next to the clips) and uses it to fit the clip to your character when they rest in different poses. See Retargeting.

Making your own

Any entity can get a brand new clip. Select it and, if it has no clips yet, the Timeline offers three cards:

  • Record: makes a clip with position, rotation and scale tracks and turns on recording, so moving the object keys it.
  • Key a property: makes a clip and asks which property to animate first.
  • Use an existing clip: opens a .anim file already in the project.

The Animation panel's Create Animation button does the same job: it writes an empty clip to animations/<entity name>.anim and adds an Animator with that clip as its default.

The Animation workspace

Switch to the Animation workspace from the workspace tabs (see Workspaces). It has three panels, with the Timeline in the bottom panel as always:

  • the stage in the middle,
  • Animation Tools on the left,
  • Animation Inspector on the right.

The stage's header: the mode switch, the model dropdown, and the Front, Side and Persp views

The stage

The stage shows the character on its own: lit, on a floor, away from the rest of your level, so nothing else gets in the way of a click. It is not a picture, though. What you do on the stage happens to the real character in your scene: turn a bone here and that is the bone the clip keys.

The dropdown in the stage's header picks the model. It lists every model in the scene and every model file in the project; picking a file that is not in the scene yet adds it at the origin (Ctrl+Z takes it back out). Selecting a model in the scene puts it on the stage too.

ToDo
OrbitRight-drag, or Alt + left-drag
PanMiddle-drag, or Shift + right-drag
ZoomMouse wheel
Frame the modelF, or the frame button in the stage's toolbar
Look from the front, the side or in perspectiveFront, Side and Persp in the header

The toolbar at the top left shows and hides the Skeleton and the Floor, and in Animate mode turns on Auto Key and Onion skinning.

Five modes

The switch in the stage's header picks what you are doing. The side panels change with it; the stage and the Timeline stay.

ModeFor
RigGiving a model a skeleton or a face rig
SkinPainting how the mesh follows the bones
ShapesSculpting blend shapes (a smile, a blink)
AnimatePosing bones and keying them
LogicThe state machine and its parameters

Rig, Skin and Shapes are covered in Rigging and Posing, Logic in The Animator. The rest of this page is about Animate and the Timeline.

Onion skinning

Turn on Onion (Animate mode only) to see faint ghosts of the character a few frames before the playhead (orange) and after it (blue). They show the arc and spacing of a motion without scrubbing back and forth. The small arrow beside the button sets how many ghosts, which sides (Before and after, Before only, After only) and how far apart they are.

Ghosts only appear on the stage, follow your edits as you make them, and hide while the preview plays.

The Timeline

The Timeline is a tab in the bottom panel. It shows the clip open on the selected entity: one row per track, a diamond per key, and the playhead.

The toolbar

  • Left: the clip picker (switch clips, Rename clip..., New clip... or Use an existing clip...), a + that makes a new clip, and the red Record button.
  • Middle: the transport (first frame, previous key, play, next key, last frame, loop) and the current time.
  • Right: row height, playback speed, snap, the Keys / Curves switch, and a ⋯ menu with the clip length, event markers, zoom, Row height (Compact, Normal, Roomy), Add property track and Save now.

Tracks and keys

The track list on the left has a Filter tracks box and a + Track button. The top row, All tracks, sums up every key in the clip: drag one of its diamonds to move every key at that moment on every track at once. Bone rows nest under their parent bone; click the arrow to fold a branch away.

Right-click a row for Delete track, or Disable track to watch the clip without it. A disabled track is dimmed and left out of playback, in the editor and in the game, until you choose Enable track.

ToDo
Select a keyClick it. Shift + click adds to the selection
Box-selectDrag across empty lane space
Move keys in timeDrag a selected key; the rest of the selection follows
Edit a key exactlyClick it without dragging to open its card
Add a key at a spotRight-click a lane, Add keyframe here
Move the playheadClick empty lane space, or drag in the lower half of the ruler
Change the clip's lengthDrag the small tab at the clip's end on the ruler
Scroll, pan, zoomWheel scrolls rows, Shift + wheel pans time, Ctrl + wheel zooms time, Alt + wheel changes row height

A run of keys on every frame, which is what an imported clip is made of, draws as one bar. Zoom in to pick out single keys.

Keying a pose or a property

  1. Select the entity and open a clip.
  2. Move the playhead to where the key should go.
  3. Change something: turn a bone on the stage, move the object, or change a value in the Inspector.
  4. Press K (over the stage or the Timeline) to key it.

Moving something on its own only changes how it looks right now. Nothing is saved into the clip until you key it, and an unkeyed pose is dropped when the playhead moves.

Other ways to key:

  • Record (or Auto Key on the stage): every change you make is keyed at the playhead as you make it.
  • The Inspector's key button: while a clip is open, every animatable field in the Inspector gets a small diamond button. Click it to key that value; if the field has no track yet, one is made.
  • + Track or Add property track in ⋯: pick a component and field to animate.

Clips save on their own a moment after each edit, so Play mode always sees the latest version.

How a key moves to the next one

A key's shape on the lane tells you how it eases into the next key:

ShapeMeaning
DiamondLinear: a straight, even move
SquareHold: the value jumps at the next key (good for blocking out poses)
CircleSmooth: eases in and out

Right-click a key, or use the buttons on its card, to change it. Property keys offer Linear, Smooth, Ease in, Ease out, Step and Bounce on the card, and the right-click menu adds Ease In-Out, Back Out (overshoot), Bounce Out and Elastic Out. Bone keys have six modes:

ModeWhat it does
AutoSmooth, with the curve worked out from the keys around it and never overshooting them. Every new key starts as Auto
LinearA straight move to the next key
ConstantHold the pose until the next key
FlatSmooth, easing out of and into the key
FreeSmooth, with a curve handle you set by hand
BrokenTwo separate handles, for a sharp change of direction

For a continuous spin keyed as rotation, keep keys less than 180 degrees apart (0, 120, 240, 360).

Curves

Switch the toolbar from Keys to Curves to see the selected track as a graph of value over time. Drag a key up and down to change its value, sideways to retime it. A smooth key shows a handle on each side: drag one to shape the curve (Alt + drag to break the two sides apart). F frames the selection; Frame all shows everything.

The loop region

The upper half of the ruler holds a blue band: the part of the clip the preview loops over. Drag its ends, or press I and O to set its start and end at the playhead, to watch one stretch of a long clip on repeat. It only affects the editor preview, never the clip itself.

Timeline shortcuts

With the mouse over the Timeline:

KeyAction
SpacePlay or pause
Home / EndJump to the start or end of the loop region
I / OSet the loop region's start / end at the playhead
← / → (or , / .)Step one frame
KKey every track at the playhead
NNew track
Delete / BackspaceDelete the selected keys
Ctrl+C / Ctrl+VCopy the selected keys / paste them at the playhead
FIn Curves: frame the selected keys
EscapeClose the key card, then clear the selection

Particles on the Timeline

When the selected entity has a particle effect, its emitters and keyed parameters appear on the Timeline too, so an explosion can be timed against a character's swing. See Particles.

Event markers

A marker is a named point in a clip: a footstep, the frame a sword connects, the moment to spawn a dust puff. Open ⋯, type a name, and choose Add at playhead. Markers draw as small flags on the ruler; right-click one to delete it.

When the game runs, every time playback passes a marker your Rust scripts receive an AnimationEvent. Every script with a hooks function hears every marker, so check source to react only to your own character:

use bevy::prelude::*;
use renzora::{ScriptCtx, ScriptHook};

fn update(_ctx: &mut ScriptCtx) {}

fn hooks(ctx: &mut ScriptCtx, hook: &ScriptHook) {
    if let ScriptHook::AnimationEvent { name, source } = hook {
        if *source == ctx.entity() && *name == "footstep" {
            info!("step!");
        }
    }
}

renzora::script!(update, hooks = hooks);

Playing animation from a script

Clips play in Play mode and in your shipped game. The Default clip starts on its own; to change clips from a Rust script, push an AnimationCommand. Put the script on the entity that has the Animator:

use bevy::prelude::*;
use renzora::{AnimationCommand, AnimationCommandQueue, ScriptCtx};

fn update(ctx: &mut ScriptCtx) {
    let me = ctx.entity();
    let moving = ctx
        .get_resource::<ButtonInput<KeyCode>>()
        .is_some_and(|keys| keys.pressed(KeyCode::KeyW));
    let clip = if moving { "walk" } else { "idle" };

    if let Some(mut queue) = ctx.get_resource_mut::<AnimationCommandQueue>() {
        queue.push(AnimationCommand::Play {
            entity: me,
            name: clip.into(),
            looping: true,
            speed: 1.0,
        });
    }
}

renzora::script!(update);

Play does nothing if that clip is already playing, so sending it every frame is fine. Switching clips fades over the Animator's Blend time.

CommandWhat it does
PlayPlay a clip (fading from the current one)
CrossfadeFade to a clip over a time you choose
Stop, Pause, ResumeStop, pause or carry on
SetSpeedChange playback speed
SeekJump to a time, in seconds
SetParam, SetBoolParam, TriggerDrive a state machine (see The Animator)
PlayOnLayer, StopLayer, SetLayerWeightDrive animation layers

Riding a moving part

An imported scene can animate its objects rather than a skeleton: doors, pistons, a camera flying down a corridor. Each moving part keeps its own name in the model. To make anything follow one of those parts, add Follow Node to it and type the part's name into Target. When you drop in a model that carries an animated camera, a scene camera that follows it is added for you, so pressing Play shows the fly-through.

Next