Manual
Manual
Animation clips
A clip is a stretch of animation that an Animator plays. Clips come with your models, or you make them in the editor as clip files. This page covers both kinds: a model's clips and their import settings, clip files, the Animation window where you edit them, the events, curves and sync markers a clip can carry, and the clips that play a sprite's frames. How an Animator picks which clip plays is on the next page, The Animator.
Two kinds of clip
| Kind | Where it comes from | Where you edit it |
|---|---|---|
| A model's clip | Imported with a glTF, GLB or FBX file, named as the file names it | The model's import settings, in the Inspector |
A clip file, .anim | Made in the editor | The Animation window |
Both kinds play the same way. A state of an animator controller plays either one, your code loads and plays either one by its key, and a clip file's events, curves and sync markers work as a model's do.
A model's clips
When the editor imports a model, it reads each of the model's clips and its skins beside its meshes. Wherever a model has clips or a skin, its prefab has an Animator at its root, which plays the clips on what is under it (see Models are prefabs).
The Animation section
Pick the model in the Project panel. Its import settings in the Inspector have an Animation section:
| Setting | What it does |
|---|---|
| Import Animation | Reads the model's clips beside its meshes. Off, only its skin is read, and another file's clips can move it. |
| Rig | The joints its meshes bend by, which a clip moves by their names. Shown, not edited. |
| Skeleton | For a file of clips exported on their own: the model the clips are for. See Clips for another model. |
| A row for each clip | Its name, its length in seconds, how many keys and curves it has, the path it is loaded by, and Loop. |
Loop starts off, so a clip plays once. Tick it for a cycle, such as a walk or a run. Loop is what a clip does when nothing else says otherwise: a controller's state, or your code, can still play it once or looping.
Changes in this section, including the events, curves and sync markers you put on a clip, are written to the model's import settings when you click Apply, and Revert puts them back. Settings you changed and did not apply are asked about before the Inspector shows something else.
A model's tile in the Project panel has an arrow that unfolds its parts beside it, its clips among them. Picking a clip there opens the model's Inspector with that clip's timeline open. Drag a clip, or a clip file, onto an animator state's Clip slot to have the state play it; a model with only one clip can be dropped there itself.
The timeline and the preview
Click a clip's name in the Animation section to open its timeline under the clips: a button back to its start, Play, the time, and the Event, Sync and Curve buttons, over a ruler of seconds. Click or drag on the ruler to move the playhead. Under the ruler are a lane for the clip's events, one for its sync markers and one for each of its curves. The Events, Curves and Sync markers sections below explain them.
The model's preview, at the foot of the Inspector, holds the model where the playhead is. Drag in it to turn round the model, and turn the wheel to move in and out. Click the clip's name again to pick no clip, and the preview shows the model as it was bound.
Clips for another model
A clip moves the bones of the animator playing it by their names. It looks for each bone by its whole path from the animator first. If the skeleton has no such path, it uses the bone whose path ends as the clip's does, and failing that, the one bone with that name. So a clip plays on any model whose bones are named alike, such as a rig and its clips exported beside it, one file each.
Set a file of clips' Skeleton slot to the model the clips are for. The preview then plays them on that model, a state's Clip list offers them under that model beside its own clips, and each clip you pick lists its Bones, folded under their count: each bone the clip moves and the bone it lands on, with None of its name in amber for one that lands on nothing.
Clip files
A clip file is an .anim file in your assets. It holds one clip: a sprite's frames, and the events, curves and sync markers a model's clip can have. To make one:
- In the Project panel, pick Animation Clip in the + menu, or New Animation Clip in a folder's right-click menu. It makes
NewAnimation.anim, empty, at 12 samples a second and looping, and lets you type its name. - In the Animation window, click Create for an entity with nothing to animate (see The Animation window).
- Drag several images or slices into the scene together, which makes a sprite and a clip of their frames (see Clips for sprites).
Pick a clip file in the Project panel, and the Inspector shows how many Frames it has and its Length, and lets you change its Samples and Loop. Double-click it to open it in the Animation window.
The file is JSON, so it reads well in version control:
{
"abyssClip": 2,
"samples": 12,
"loop": true,
"frames": [
{ "time": 0, "image": "sprites/coin.png", "guid": "bd0682ba36624411a3b60ffee2585e2a", "slice": "e1f027e90c274848" },
{ "time": 0.08333, "image": "sprites/coin.png", "guid": "bd0682ba36624411a3b60ffee2585e2a", "slice": "11ee6444f37c5ed7" }
],
"events": [ { "time": 0.5, "type": "Footstep", "fields": { "Foot": 1 } } ],
"curves": [ { "field": "Footing.Plant", "smooth": true, "keys": [[0, 0], [0.5, 1, "constant"], [0.75, 0]] } ],
"markers": [ { "time": 0, "name": "LeftDown" } ]
}A frame names its image by its path and its identity, so an image you move or rename is still found, and a slice by its own identity. A frame is shown until the next one, and the last for one sample. A clip is as long as what is on it reaches, and at least one sample long.
The Animation window
Open it with Window ▸ Animation (Ctrl+6). It edits clip files on a timeline of keys.
The window follows the entity picked in the Hierarchy and lists the clips of the controller its Animator names: each state's clip and the clips of its blend spaces. When you pick something with no Animator of its own, such as a part of a character, it follows the nearest Animator above it. A clip file double-clicked in the Project panel opens on its own, with no entity.
Pick the clip to edit from the list at the left of the window's row. A model's clip is listed grayed, since its import settings edit it; picking it offers Show Model, which shows the model in the Project panel. Create New Clip, at the foot of the list, adds a clip for the entity it follows.
For an entity with nothing to animate, the window says so and offers Create. It makes a clip named after the entity in the open scene's folder. If the entity's Animator names a controller, a state that plays the new clip is added to the controller's first layer. If not, the editor makes a controller beside the clip and gives the entity an Animator that names it.
The row
| Control | What it does |
|---|---|
| The clip list | Picks the clip to edit, and has Create New Clip |
| Record | For a UI document's element only: keys what you change, at the playhead (see UI elements) |
| Curves | Shows the Curves view in place of the dopesheet, and back |
| Start, frame back, Play, frame on, end | Move the playhead, or play the clip |
| The frame number | Where the playhead is, from 0: drag or type it |
| Samples | How many frames a second the clip's keys are placed at |
| Loop | Whether it plays round and round when nothing says otherwise |
| Event and Sync | Put an event or a sync marker on the clip at the playhead |
The dopesheet
The ruler at the top counts seconds and frames: 1:06 is one second and six frames at the clip's samples. Click or drag on the ruler to move the playhead, which always lands on a whole frame.
Under the ruler, each row has its name in a column on the left and its lane on the right. Drag the column's edge to make it wider. The rows are, from the top:
- A row of every key: a diamond at each time anything in the clip is keyed.
- Sprite.Image, the sprite's frames, each drawn as its picture, where the clip has frames or the entity has a sprite.
- Events and Sync, the clip's events and sync markers.
- Each curve, grouped by what it animates, with a color's parts folded under the color.
A curve's row shows its value at the playhead beside its name. Drag or type the value, or pick a color from its swatch, to key it at the playhead.
| Do this on a lane | To |
|---|---|
| Click a diamond, a frame or a mark | Pick it alone |
| Ctrl and click | Add it to what is picked, or take it out |
| Shift and click | Pick everything from the last one clicked to it, across the rows between |
| Drag from where nothing is | Pick what the rectangle covers |
| Drag what is picked | Move it along by whole frames, shown where letting go puts it |
| Alt and drag | Copy what is picked to where you let go |
| Escape, while dragging | Let the drag go |
| Double-click where nothing is | Key the row there |
| Right-click | Add Key where you clicked, and Delete, Copy and Paste for what is picked; for keys, Smooth, Linear and Constant |
Right-click a row's name for Add Key at the playhead and, for a curve, Remove Property.
While the window has the keyboard or the pointer:
| Key | What it does |
|---|---|
| Delete | Takes out what is picked |
| Ctrl+C, Ctrl+V | Copies what is picked, and pastes it at the playhead |
| Ctrl+A | Picks everything |
| K | Keys the rows picked, or every curve, at the playhead |
| Comma, Period | A frame back, a frame on; with Alt, to the previous or next key |
| Home, End | To the clip's start, or its last frame |
| Space | Plays, or stops |
| F | Fits what is picked, or the whole clip, in the window |
| Escape | Picks nothing |
The wheel scrolls the rows. Ctrl and the wheel zoom the timeline about the pointer, Shift and the wheel pan it, and so does dragging with the middle button.
Curve, under the rows, adds a curve to the clip (see Curves). Under it, the window shows what you picked: an event's fields, a sync marker's name, or a curve's field and its picked key.
Every edit in the window is written to the clip file at once, and Ctrl+Z takes it back.
The Curves view
Curves, in the row, puts a graph in place of the lanes. It draws the curves of the rows picked by name, or every curve when none is picked, together on a value axis, each in its own color: a color's red, green, blue and alpha in theirs. The names stay on the left, picked and folded as on the dopesheet.
Keys are picked as on the dopesheet: a click, Ctrl, or a rectangle. Dragging what is picked moves it along the clip on whole frames and up and down in value. Hold Shift to keep the drag to the way it went most, Alt to leave a copy behind, and press Escape to let it go. A double-click keys the curve nearest the pointer there. The wheel zooms the values about the pointer and the middle button pans them, while Ctrl and Shift with the wheel zoom and pan the clip; F fits both.
Right-click a key, in the graph or on the dopesheet, to say how the curve goes on from it:
| Choice | How the curve goes on to the next key |
|---|---|
| Smooth | Along a curve |
| Linear | In a straight line |
| Constant | It holds the key's value, then jumps to the next key's. The key is drawn as a square. |
Sprite frames
Drop images or slices from the Project panel onto the Sprite.Image row to add frames. They go in a frame apart from where you let go, in the natural order of their names, so walk_2 comes before walk_10, and each replaces a frame already at its time. Frames you drag along land on whole frames, replacing what is there.
While the window is shown, the sprite it follows is drawn at the playhead's frame. That picture is a stand-in, never saved with the scene.
Events
An event is a moment of a clip that your code hears as the clip plays past it, such as a foot landing. Each event is a struct of your game's marked [AnimationEvent], with fields you fill in on the clip; Animation events in code shows how to declare one and read it.
Click Event, in a model clip's timeline or the Animation window's row, to list your game's events, and pick one to put it on the clip at the playhead. It shows as a lightning mark on the Events lane, which you drag to move. With an event picked, its time, a button that takes it off, and its fields are shown under the lanes, edited as a component's fields are.
An event fires as a playing clip passes it, on every lap of a loop. When an animator plays several clips at once, as one fades into another, only the clip drawn most fires its events, so a footstep is heard once while a walk fades into a run. A clip that a model's preview holds fires none.
A clip keeps its events by the struct's name, and their fields by theirs. Rename the struct and the events already on clips keep the old name.
Curves
A curve writes a field of a component on the animator as the clip plays. It names the component and the field: MyGame.Footing.Plant is the Plant field of the animator's Footing component, which Footing.Plant names too while no other component is called Footing. Curve lists every number and flag of the components your game's C# declares. Pick one, and the curve goes on the clip with a key at the playhead.
With a curve picked, the panel under the lanes shows its field, Smooth, which draws it as a curve through its keys rather than straight lines between them, + Key, which keys it at the playhead at the value the curve has there, and a button that takes the curve off the clip. A key picked shows its time and value to change, and a button that takes it off; taking off a curve's last key takes off the curve.
As the clip plays, the field holds the curve's value at the clip's time: a whole number rounded, and a flag on from a half. While one clip fades into another, the field is their curves' values weighed by how much of each is drawn. The engine writes it after it moves the clips each frame, so a system reads the value of the last frame.
A curve is a way to give a clip data your systems react to, such as how fast a run says the character goes, or whether a foot is planted:
[AbyssComponent]public partial struct Footing{ public float Plant; // keyed by the Walk and Run clips}Sync markers
A sync marker names a moment of a clip, such as LeftDown, where the left foot lands. Markers of the same name on two clips are the same moment.
Click Sync to pick a name already in use, such as one on the model's other clips, or type a new one and press Enter. The marker goes on the clip at the playhead as a pennant on the Sync lane, which you drag to move. With one picked, you can change its time and its name below the lanes, or take it off.
When an animator fades from one clip into another and both have markers, the clip faded into starts as far between its markers as the other clip is between its own markers of the same names. A walk fading into a run keeps its feet in step. Only the start is lined up; then each plays at its own speed, and a cut, a fade of no time, starts at the beginning.
Clips for sprites
To animate a sprite from a set of images or slices, pick them together in the Project panel with Ctrl+click and drag them onto the Scene panel or the Hierarchy. The editor makes a sprite showing the first frame, with an Animator running a controller that plays a clip of all of them, 12 frames a second, looping, in the natural order of their names. The clip and the controller are made beside the first image and named after it: walk.anim for walk_0.png to walk_7.png.
A clip file's frames are shown by the sprite on the entity with the Animator, so edit the frames and their timing in the Animation window. Sprites covers the sprite itself and cutting images into slices.
UI elements
The elements of a UI document are animated the same way, by an Animator on an element and clip files. With a document's element picked, the Animation window works on what the Animator moves under it:
- Add Property, under the rows, lists each element the Animator moves and the values of it a clip can animate: Position, Scale and Rotation, Opacity where it has a UI Opacity, Background Color, Border Color, Text Color, Image Color, and the Left, Top, Width and Height of its layout. Each is keyed at the playhead from what the canvas shows.
- Record, in the row, keys at the playhead what you change in the Inspector or on the canvas, in place of changing the document. The button and the ruler are red while it is on.
- The canvas shows the clip at the playhead, without changing the document.
A value a clip animates goes back to what the document's style sheets say once no clip writes it, so a color faded in by a clip is the sheet's again when the clip stops. Create on an element ticks its Animator's Unscaled Time, so a menu animates while the game is paused. UI documents covers documents.
Clips in code
A clip is loaded by its key once its model or its clip file is Addressable (see Keys in code). A model's clips have keys under the model's key, and a clip file has its own:
ClipId run = context.Assets.LoadClip(Addresses.Characters.Fox.Run); // the clip Run of characters/fox.glbClipId walk = context.Assets.LoadClip(Addresses.Sprites.Walk); // sprites/walk.animcontext.Assets.Release(walk); // gives back one loadA clip is ready to play as soon as it is loaded, and moves what it plays on once it has landed. Loads are counted, as other assets' are. Playing clips from code shows how to play one.
A clip your scenes use through a controller doesn't need to be Addressable: a build packs each controller with the models and clip files its states play.
In the Scripting API
- ClipId and ClipAddress: a clip loaded, and the key it is loaded by.
- AnimationEventAttribute: a struct a clip fires as an event.
- AssetAccess: clips loaded and let go of from a system.
- AnimationClipFiles: clip files, by their extension.
