Skip to content

Animation

For a logo intro with two images appearing in turn and a sound cue, use the Sequencer. For a character that switches between idle, walk and jump in response to gameplay, use an Animator Controller. The file extension tells you which editor opens each asset.

What you want to do Where to start What plays it in the scene
Time movement, visibility, sound and camera cues in 2D or 3D Add → New Animation opens the Sequencer and creates an .estimeline Assign the file to Timeline Player → Timeline and tick Playing
Animate a sprite sheet or a sequence of images Right-click a texture and choose Create Sprite Animation to create an .esanim Right-click the clip and choose Create Animated Sprite for an entity with Sprite and Sprite Animator
Switch between actions such as idle and walk using parameters Add → New Animation Controller creates an .esanimator and opens the state graph Add Animator to the target entity and select the controller in Controller
Ease a button, zoom a camera or interpolate a property from code Call Tween in a script The script starts the tween

The Content Browser Add menu with New Animation in the middle and New Animation Controller near the bottom

New State Machine creates an .esfsm for gameplay logic. Choose New Animation Controller in the same menu for a character animation graph.

Choose Add → New Animation. Select a visible object in the World Outliner, bind it in the Sequencer and add a Transform.position.x property track. Give the first frame and the frame one second later different values. Drag the playhead and watch the object move in the scene viewport. Click Save in the Sequencer. For scene playback, assign the same timeline to Timeline Player → Timeline on the target, tick Playing and save the scene.

Two position keys in the Sequencer with the second key set to 120

If Bindings shows a single row, add a named binding from the track menu in the Sequencer. For an audio item with no sound assigned, select the item and open its Details.

Follow the two-key walkthrough · Choose a sound for an audio track · Bind a track to another entity

  1. Right-click a sprite sheet in the Content Browser and choose Create Sprite Animation. The Sprite Animation panel opens. Under Frame source, adjust Cell W, Cell H, Margin and Spacing, then click or drag across grid cells to append frames. If you have separate images, select them together, right-click and choose Create Sprite Animation from N Images. The frames start in filename order, with run_2 before run_10.
  2. Press play in the panel to check the motion. Drag a frame block to reorder it or its right edge to change its duration. Select a frame to edit duration, size, offset and anchor in Details. Frames refer to grid cells when you re-slice the sheet. Out-of-grid frames appear red.
  3. Click Save. Right-click the saved .esanim and choose Create Animated Sprite. Select the new entity in the World Outliner. It has Sprite and Sprite Animator, with Clip already assigned. Save the scene and press play on the main toolbar to see the frames change. Enable Preview FX in the viewport to see animated sprites while editing.

A four-frame walk cycle and its playback preview in the Sprite Animation panel If you registered a clip called walk with registerClip, you can switch to it on entering a state. For a file assigned in the editor, keep the asset reference in Clip.

import type { SpriteAnimatorData } from 'esengine';
function startWalk(animator: SpriteAnimatorData) {
animator.clip = 'walk';
animator.speed = 1.5;
animator.playing = true;
}
Property Type Default Description
clip asset '' Current clip (an anim-clip asset name).
speed number 1 Playback speed multiplier.
playing boolean true Whether playback is advancing.
loop boolean true Repeats when both the component and the clip enable looping. Otherwise holds the last frame.
enabled boolean true Disable to freeze the animator.
finished boolean false Read-only: latched when a one-shot clip completes. Raising playing on a finished animator replays from frame 0.
currentFrame number 0 Read-only: the frame index being shown.
frameTimer number 0 Read-only: time accumulated on the current frame.

For finer control, the SpriteAnimation resource jumps to a specific frame or a named label and registers clips at runtime:

import type { SpriteAnimationAPI, SpriteAnimatorData } from 'esengine';
function startAttack(sprites: SpriteAnimationAPI, animator: SpriteAnimatorData) {
sprites.gotoLabel(animator, 'attack', true);
}

This example uses a code-registered clip with a frame label named attack. Call it once on entering the attack state. To play from a specific frame, use sprites.gotoFrame(animator, 0, true).

Method Description
gotoFrame(animator, index, andPlay?) Jump to a frame index (optionally start playing).
gotoLabel(animator, label, andPlay?) Jump to a named label in the clip.
registerClip(clip) Register a SpriteAnimClip at runtime.
getClip(name) Look up a registered clip.

Events crossed in one update run in playback order, including loop boundaries. A long update fast-forwards complete loops and coalesces each declared event to at most one notification per update, avoiding a burst of delayed sounds or hits. Updates with no elapsed time do not repeat the initial frame event. gotoFrame(animator, index, false) and gotoLabel(animator, label, false) pose the selected frame on the next animation update without advancing or firing events. Inside a frame callback, change playback through gotoFrame / gotoLabel rather than calling update again: nested updates on the same animation API are ignored.

In Sprite Animation → Events, select a frame, click Add event and click its flag to edit Name. For example, name a footfall frame footstep. Subscribe once during game initialization to play a sound when it fires.

import { Audio, defineSystem, Res, SpriteAnimation } from 'esengine';
app.addStartupSystem(defineSystem([Res(SpriteAnimation), Res(Audio)], (sprites, audio) => {
sprites.onEventGlobal((event) => {
if (event.name === 'footstep') audio.playSFX('assets/sfx/step.wav');
});
}));
Method Description
onEvent(entity, handler) Listen to one entity’s frame events. Returns an unsubscribe function.
onEventGlobal(handler) Listen to every entity’s — the handler receives the entity too.

Drop a .aseprite (or .ase) into the project and the import writes the products for you: the composited sheet as a .png beside it, and one .esanim per tag — hero_walk.esanim, hero_jump.esanim — carrying each frame’s own duration and the direction the tag plays in. A tag with no repeat count loops; one that counts its plays does not. A file with no tags gets a single clip over every frame.

What is composited is what the artist sees: every layer they left visible, with its blend mode and opacity, and nothing from a group they switched off. A tilemap layer is drawn from a tileset rather than from pixels and is reported instead of silently arriving blank.

The sheet’s texture arrives set to nearest filtering with compression off — the two settings pixel art always wants and never gets by default — and with its cell grid filled in, so a Sprite can pick a frame of it straight away. Change either setting and it stays changed; the grid is re-derived on every import, because it is the source’s canvas size rather than a preference.

Editing the file and saving it re-imports it in place: same uuids, same refs, new pixels. Right-click → Reimport does the same on demand.

A sheet’s cells are all the same size, so one Sprite.size fits every frame of it. Separate images are not: a 96×64 attack frame and a 48×96 idle frame drawn at one size are both wrong. Tick Frame Sizes and the clip owns Sprite.size during playback — each frame draws at its own natural size (its texture’s pixels, or its sheet cell), or at a size you give it.

That also unlocks offsets. An offset shifts a frame’s artwork, in the same units as the size, and is folded into the frame’s anchor when the clip loads — so nothing downstream has to know about it. Authoring the shift in units rather than as a raw anchor is the point: the same offset is the same visual shift on frames of any size, which a normalized anchor cannot be. Drag the frame in the viewport to set one, or type it in the inspector.

// step.esanim — three images of different sizes, one of them nudged right
{
"version": "1.5",
"fps": 6,
"frameSizing": "frame",
"pivot": { "x": 0.5, "y": 0 },
"frames": [
{ "texture": "@uuid:…" },
{ "texture": "@uuid:…", "offset": { "x": 20, "y": 0 } },
{ "texture": "@uuid:…", "duration": 0.35 }
]
}

A clip that declares neither leaves Sprite.size exactly as the entity set it, so clips written before this existed play unchanged. Unticking the switch drops the mode and every per-frame size and offset, which is the way back to that.

An anchor is the point a sprite sits, rotates and scales about — Sprite.pivot, normalized inside the frame, (0,0) bottom-left and (0.5,0.5) centered. When the artwork shifts inside its cell from frame to frame, one entity-wide anchor makes the character slide around; anchoring per frame pins whatever has to hold still — feet on the ground, a hand on a weapon.

Tick Anchor in the Sprite Animation panel’s preview bar and a crosshair appears over the current frame. Drag it (or type the X / Y beside it) to anchor that frame. The hairlines run the width of the stage, so with onion skin on you can line each frame’s feet up against its neighbours. A frame anchored on its own gets an amber dot in the strip, and × clears that override so the frame falls back to the clip’s anchor — which lives in the Details inspector as Default Anchor.

Resolution order: the frame’s own anchor, else the clip’s, else centered. A clip that authors no anchor at all leaves Sprite.pivot exactly as the entity set it, so existing projects are untouched until you tick the box; unticking clears the clip anchor and every frame override and returns to that hands-off behaviour.

// walk.esanim — the clip stands on its feet, one frame leans back
{
"version": "1.4",
"fps": 10,
"pivot": { "x": 0.5, "y": 0 },
"frames": [
{ "cell": 0 },
{ "cell": 1, "pivot": { "x": 0.47, "y": 0 } }
]
}

Anchors are the clip’s business only while it plays a frame: nothing stops a Transform or a tween from moving the entity as usual.

The .esanim document is plain data, so a clip can also be built at runtime: createAnimClip starts a sheet-sliced clip, you append { cell } frames, parseAnimClipData resolves it into a runtime SpriteAnimClip, and registerClip makes the name available to every SpriteAnimator:

import {
defineSystem, Res, Assets, SpriteAnimation,
createAnimClip, parseAnimClipData,
} from 'esengine';
const registerRun = defineSystem([Res(Assets), Res(SpriteAnimation)], async (assets, sprites) => {
const tex = await assets.loadTexture('assets/textures/run-sheet.png');
// A 32×32 grid over the sheet; frames reference grid cells (row-major).
const data = createAnimClip('assets/textures/run-sheet.png', 32, 32, tex.width, tex.height);
data.fps = 10;
for (let cell = 0; cell < 6; cell++) data.frames.push({ cell });
const handles = new Map([['assets/textures/run-sheet.png', tex.handle]]);
sprites.registerClip(parseAnimClipData('run', data, handles));
// Any SpriteAnimator can now set clip = 'run'.
});
Helper Description
createAnimClip(texture, cellWidth, cellHeight, pageWidth, pageHeight) A fresh sheet-sliced AnimClipAssetData (fps 12, loop: true, margin/spacing 0, no frames yet).
createAnimClipFromTextures(textures) A fresh clip over a sequence of per-frame textures — no sheet, and owning size from the start.
parseAnimClipData(name, data, textureHandles, textureSizes?) Resolve asset data into a runtime SpriteAnimClip — each frame gets its texture handle, UV window, and (for a clip that owns size) the size it draws at. Pass textureSizes so a per-texture frame has a natural size to fall back on.
parseAnimClipAsset(json) / serializeAnimClip(data) Parse / write the .esanim JSON document (the pair round-trips).
animClipCellRect(sheet, cell) / animClipCellUv(sheet, cell) Pixel rect / UV window of a grid cell — what a Sprite shows for that frame.
animClipFramePivot(data, frame, size?) The anchor a frame renders with — its own, else the clip’s, else centered, with the frame’s offset folded in when a size is given. null when the clip authors none (leave Sprite.pivot alone).
animClipDrivesPivot(data) Whether the clip authors anchors at all.
animClipFrameSize(data, frame, natural?) The size a frame draws at — its own, else the natural one you pass. null when the clip does not own size (leave Sprite.size alone).
animClipDrivesSize(data) Whether the clip owns Sprite.size — set outright, or implied by any frame’s size or offset.

Driving clips from a state machine — no code

Section titled “Driving clips from a state machine — no code”

The FSM/BT built-ins drive flipbooks as data. An action’s optional argument carries the clip, so idle/run/attack switching is pure .esfsm on the existing state-machine canvas:

Name Kind Description
spriteAnim.play action Play. With a clip argument, switch to that clip (rewinds to frame 0). Safe on onUpdate — same-clip play while playing is a no-op.
spriteAnim.restart action Unconditional rewind + play (re-trigger a one-shot mid-flight).
spriteAnim.stop action Pause playback.
spriteAnim.finished condition True once a one-shot clip completed — onEnter: spriteAnim.play + a spriteAnim.finished transition is a self-contained attack state.

The Tween resource interpolates a property from one value to another over a duration. to(entity, target, from, to, duration, options?) returns a handle. Call this function once, for example on a button press.

import { EasingType, LoopMode, TweenTarget, type Entity, type TweenAPI } from 'esengine';
function moveLogo(entity: Entity, tween: TweenAPI) {
return tween.to(entity, TweenTarget.PositionX, 0, 200, 1, {
easing: EasingType.EaseInOutQuad,
delay: 0.2,
loop: LoopMode.PingPong,
loopCount: 3,
});
}

TweenTarget selects the property to drive:

Group Values
Position PositionX, PositionY, PositionZ
Scale ScaleX, ScaleY
Rotation RotationZ
Color ColorR, ColorG, ColorB, ColorA
Size SizeX, SizeY
Camera CameraOrthoSize
Option Type Default Description
easing EasingType Linear Easing curve (see below).
delay number 0 Seconds to wait before starting.
loop LoopMode None None / Restart / PingPong.
loopCount number 0 Number of loops; -1 = forever.

EasingType covers Linear, the quad/cubic/quart/quint/sine/expo/circ/back/elastic families (EaseIn* / EaseOut* / EaseInOut*), the bounce family (EaseInBounce, EaseOutBounce, EaseInOutBounce), Smoothstep and Smootherstep, Step, and CubicBezier — use a custom bezier with the handle’s .bezier(p1x, p1y, p2x, p2y).

Every EasingType plotted as a curve from 0 to 1

Each easing plotted (progress t left→right, eased value bottom→top) — these are the engine’s exact curves. Back and Elastic overshoot past the 0–1 band; Step holds until the end.

The returned TweenHandle chains and controls playback:

// Chain: run one after another (a squash-and-stretch pop).
tween.to(e, TweenTarget.ScaleX, 1, 1.4, 0.15)
.then(tween.to(e, TweenTarget.ScaleX, 1.4, 1, 0.15))
.bezier(0.2, 0, 0, 1);
tween.parallel([...]); // run several at once (a group)
tween.sequence([...]); // run tween factories in order
tween.delay(0.5); // a timed gap
tween.cancel(handle); // stop one
tween.cancelAll(entity); // stop everything on an entity
Method Description
to(entity, target, from, to, duration, opts?) Tween a component property; returns a TweenHandle.
value(from, to, duration, cb, opts?) Tween a plain number, delivered to cb each frame.
parallel(tweens) Run several tweens together as a group.
sequence(factories) Run tween factories one after another.
delay(seconds) An empty timed gap (for use in sequences).
cancel(handle) / cancelAll(entity) Stop one tween, or all on an entity.

TweenHandle has .then(next), .bezier(...), .pause(), .resume(), and .cancel().

tween.parallel returns a TweenGroup and tween.sequence a TweenSequence — parent-level handles over their members. Both expose state (a TweenState), pause() / resume() / cancel() that fan out to every member, and onComplete(cb):

const popX = tween.to(e, TweenTarget.ScaleX, 1, 1.3, 0.2);
const popY = tween.to(e, TweenTarget.ScaleY, 1, 1.3, 0.2);
tween.parallel([popX, popY]).onComplete(() => spawnSparkles());
tween.sequence([
() => tween.to(e, TweenTarget.PositionY, 0, 60, 0.3),
() => tween.delay(0.2),
() => tween.to(e, TweenTarget.PositionY, 60, 0, 0.3),
]).onComplete(() => landDust());

Always create groups and sequences through the Tween resource — the resource registers them with its internal poller (TweenCompositionManager), which is what fires onComplete and advances a sequence to its next factory. A hand-constructed new TweenGroup(...) is never polled.

tween.value(...) and tween.delay(...) return a ValueTweenHandle — the same control surface (state, .pause() / .resume() / .cancel(), .bezier(...)) plus .then(next), which chains another value tween or anything pausable/resumable (a group, a sequence). TweenHandle.then likewise accepts a ValueTweenHandle, so property tweens and value tweens mix freely in one chain.

Reach for the shorthand helpers (tween.parallel / tween.sequence / tween.delay / handle .then) first; the classes are what those calls hand back — you only name TweenGroup / TweenSequence / ValueTweenHandle when storing a handle to pause, cancel, or observe the composition later.

  1. Prepare a clip with visible motion. For example, save the two distinct position keys from the Sequencer walkthrough as assets/Logo.estimeline, or prepare a multi-frame sprite clip such as assets/Walk.esanim.

  2. Choose Content Browser → Add → New Animation Controller to create an .esanimator. Click the Idle node in the graph and change Kind from None to Clip on the right. You can test this single initial state before adding transitions or parameters.

  3. In 0.112.0, Clip is a text field. Enter the actual project path, such as assets/Logo.estimeline, press Tab to commit the edit and set Played by to Timeline. For an .esanim, enter its own path and choose Sprite sheet. Click Save in the controller panel.

    The initial Idle state set to Clip, with assets/Logo.estimeline entered and Played by set to Timeline

  4. Select the object to animate in the World Outliner. In Details → Add Component, add Animator and select the saved .esanimator in Controller. In builds with controller-driven sprite playback, add Animator to an entity with Sprite to play and display an .esanim. If the entity already has a Sprite Animator, the controller uses that player.

  5. Save the scene and press play on the main toolbar. Watch the object move or change frames in the scene. Clicking a graph node opens its properties. This example uses a controller for property animation. For timed visibility, audio or camera cues, use the Sequencer and Timeline Player.

For an intro that plays Nexon and then Wizet, no parameter condition is required. The green triangle marks the initial state. The scene entity enters that state when its Animator → Controller references this controller and the scene runs.

  1. Select the edge from Nexon to Wizet. If it reads ⚡ toWz, click × on that condition under Transition → Conditions, then tick Has exit time. You can leave toWz in the Parameters list. Keeping the trigger condition on the edge requires a call to anim.setTrigger(entity, 'toWz') for this entity.
  2. Make the first clip play once. In 0.112.0, edit the clip asset itself. For an .estimeline, open it, click the Clip settings icon in the Sequencer, choose Once in its Loop row and save. For an .esanim, turn Loop off in Sprite Animation and save. In builds with the state playback fix, you can also select the Nexon node and set its Wrap Mode to Once.
  3. Save the controller and scene, then press play on the main toolbar. With no conditions and Has exit time checked, the transition waits for the end. With no conditions and the box unchecked, it takes the transition on the first update and the opening state can pass unseen. A looping first clip keeps the controller waiting.

The transition to Run with Has exit time checked and the conditions list empty

No motion from the first frame? Click the initial state and check the clip and Played by. An @uuid:… on the node is a project asset reference. To identify its type, inspect the referenced asset. In the World Outliner, select the entity that should animate and check its Animator → Controller. Place Animator on the Sprite you want to animate. The controller can advance states and dispatch frame events on an entity without a Sprite. A Sprite on that entity displays the frames. For 0.112.0, follow the steps above to keep the player and load both clips.

Nexon in an editor with the fix, showing its sprite sheet player and the hint to add Sprite to the same entity to display the frames

  1. Click + State at the top of the graph, name it Run on the right and assign a second visible clip. Hover over Idle and drag the connector on its right edge onto Run. The edge reads always until you give it a condition.
  2. Click + next to Parameters, name the new parameter speed and leave its type as Float. Click always on the edge, then + beside Conditions in the Transition inspector. Select speed, set Op to > and enter 0. In 0.112.0 the initial operator is ⚡. Change it to > to compare the float.
  3. Save the controller and the scene. During play, calling anim.setFloat(entity, 'speed', 1) for this entity transitions it from Idle to Run. To return to idle when the speed drops to zero, drag another edge from Run to Idle and give it the return condition.

Transition inspector showing Run as the target and speed greater than zero as its condition

The following character graph uses separate conditions for moving and jumping. Gameplay code sets their parameters through AnimatorController.

A configured Animator graph with Idle, Move and Hop states, transitions and the Parameters panel

import type { AnimatorControllerAPI, Entity } from 'esengine';
function updateSpeed(anim: AnimatorControllerAPI, entity: Entity, speed: number) {
anim.setFloat(entity, 'speed', speed);
}
function onJumpPressed(anim: AnimatorControllerAPI, entity: Entity) {
anim.setTrigger(entity, 'hop');
}
Animator field Type Default Description
controller string '' An .esanimator asset ref (what the editor writes) or a name passed to registerController in code.
avatar string '' An .esavatar asset saying how this rig spells the joints the clips name (see Avatars).
currentState string '' The base layer’s active state, as a /-separated path for nested machines (seeded from the controller’s initial state).
layerStates string[] [] The active state of each layer above the base one, in layer order (the base layer’s is currentState).
enabled boolean true Disable to freeze the state machine.
AnimatorController method Description
setFloat(entity, name, value) Set a float parameter (blends / transition conditions).
setBool(entity, name, value) Set a bool parameter.
setTrigger(entity, name) Fire a one-shot trigger.
resetTrigger(entity, name) Clear a trigger before it’s consumed.
getFloat(entity, name) / getBool(entity, name) Read a parameter back.

A state’s motion can be a sprite clip, a Spine animation, or a timeline clip (which is how a skinned 3D rig is animated), so one state machine handles a whole character. A transition can also carry a duration (seconds) to crossfade from the state being left into the one being entered; it is honoured wherever both motions can be sampled, and a sprite sheet is switched instead, having nothing to be halfway between.

Parameters come in three types (AnimatorParamType): 'float', 'bool', and 'trigger'. Conditions compare them with gt / lt / eq / neq (numeric, with a value), true / false (bool), or trigger (fires once and is consumed). There is no separate int type — drive whole numbers through a float parameter and eq / neq.

A combo is a transition that may only be taken during part of a clip. Declare that part as a window on the clip (a customEvent with a duration, here named combo) and give the transition a window condition, whose param names it:

{ "to": "Attack2", "conditions": [
{ "param": "attack", "op": "trigger" },
{ "param": "combo", "op": "window" }
] }

It holds while the state being left has that window open over the frame being stepped, so a combo window shorter than a frame is not skipped.

A trigger stays set until a transition uses it. For an attack that is wrong both ways: a press a little before the window should still chain, and a button mashed during the windup should not fire another attack the moment this one ends. Give the trigger parameter a buffer, in seconds of animator time, and a press is remembered for that long and then dropped:

{ "name": "attack", "type": "trigger", "buffer": 0.25 }

Pressing again restarts the buffer. A buffer of 0 is the next update only. In the Animator editor the buffer is the number beside a trigger parameter, and a condition whose operator is in window takes the window’s name instead of a parameter.

A chain reached from any state would win over the combo: any-state transitions are checked first. Leave the attack trigger out of the any-state list and put it on the states an attack may start from.

A 1D blend on speed selecting idle / walk / run by threshold

A 1D blend: a float parameter picks the clip whose threshold is the highest one at or below it — here idle / walk / run as speed rises, with no transitions between them.

A state can carry a 1D blend instead of a single clip: a float parameter selects between AnimatorBlendThreshold stops. For sprite clips, which play one at a time, this is a selection by threshold — the stop with the greatest value at or below the parameter wins (below all stops, the first one plays). Each threshold is { value, clip, speed?, loop? }; per-threshold speed / loop override the state’s own. The selection re-evaluates every frame, so a rising speed parameter walks idle→walk→run with no transitions:

import { defineSystem, Res, AnimatorController, type AnimatorControllerDef } from 'esengine';
const movement: AnimatorControllerDef = {
parameters: [{ name: 'speed', type: 'float', default: 0 }],
initialState: 'move',
states: [{
name: 'move',
blend: {
parameter: 'speed',
thresholds: [
{ value: 0, clip: 'idle' },
{ value: 0.5, clip: 'walk' },
{ value: 4, clip: 'run', speed: 1.2 },
],
},
transitions: [],
}],
};
const setup = defineSystem([Res(AnimatorController)], (anim) => {
anim.registerController('movement', movement);
});

The pure helper selectBlendClip(blend, value) returns the threshold a value selects — handy for tooling or tests.

A blend over motions that can be sampled (timeline clips driving a skeleton or any component field) does not pick: it mixes the stops either side of the parameter, at a shared phase rather than a shared second, so a 2 s idle and a 0.6 s run keep their feet together. Write it with a motion instead of the single-kind fields: { kind: 'blend1d', parameter, thresholds: [{ value, motion }] }, where a stop’s motion can itself be another blend. For a locomotion that turns, blend2d places its stops in the plane two parameters span — { kind: 'blend2d', parameterX, parameterY, points: [{ position: { x, y }, motion }] } — and mixes the points around the sample (a sample standing on a clip plays that clip alone; one outside the hull is held by its nearest edge). The state inspector offers None / Clip / Blend 1D / Blend 2D, so none of this needs a hand-edited file.

For skeletal characters, a state can instead carry a spine motion (AnimatorSpineMotion, { animation, loop? }): on entry the controller sets that Spine animation (loop defaults true) and leaves track playback and mixing to the Spine runtime — it never touches SpriteAnimator. States are exclusive: exactly one of clip, blend, spine, motion (the general form: any registered kind, sprite or timeline, or a blend1d / blend2d over them), or stateMachine.

A state carrying a stateMachine (AnimatorSubMachine) is a container: it plays no motion of its own. On entry the machine descends into the sub-machine’s initialState; the container’s own transitions are the exit edges, evaluated from every leaf inside it. A sub-machine can declare its own anyStateTransitions, checked from all of its sub-states. Animator.currentState holds the full /-separated path (STATE_PATH_SEP), e.g. locomotion/run:

import { defineSystem, Res, AnimatorController, type AnimatorControllerDef } from 'esengine';
const player: AnimatorControllerDef = {
parameters: [
{ name: 'speed', type: 'float', default: 0 },
{ name: 'jump', type: 'trigger' },
],
initialState: 'locomotion',
states: [
{
name: 'locomotion', // container: no motion of its own
stateMachine: {
initialState: 'idle',
states: [
{ name: 'idle', clip: 'idle', transitions: [
{ to: 'run', conditions: [{ param: 'speed', op: 'gt', value: 0.1 }] },
] },
{ name: 'run', clip: 'run', transitions: [
{ to: 'idle', conditions: [{ param: 'speed', op: 'lt', value: 0.1 }] },
] },
],
},
// Exit edges — leave the whole machine from idle OR run.
transitions: [{ to: 'jump', conditions: [{ param: 'jump', op: 'trigger' }] }],
},
{ name: 'jump', clip: 'jump', loop: false, transitions: [
{ to: 'locomotion', conditions: [], hasExitTime: true }, // back in at idle
] },
],
};
const setup = defineSystem([Res(AnimatorController)], (anim) => {
anim.registerController('player', player);
});

Entering locomotion lands on locomotion/idle; the jump trigger exits from either leaf; when the one-shot jump clip ends, hasExitTime re-enters the container at its initial state. Transition priority, highest first: top-level any-state → each enclosing machine’s any-state (outermost in) → the leaf’s own transitions → container exit edges (innermost out).

The path machinery is exposed as pure functions (an AnimatorScope is the shape shared by the top-level controller and every sub-machine):

import { enterStatePath, leafStateOf, evaluateAnimatorPath } from 'esengine';
enterStatePath(player, 'locomotion'); // ['locomotion', 'idle']
leafStateOf(player, 'locomotion/run')?.clip; // 'run'
evaluateAnimatorPath(player, 'locomotion/idle', { speed: 3 }, new Set());
// → { nextPath: 'locomotion/run', consumedTriggers: [] }
Helper Description
enterStatePath(scope, name) Descend from a state to its concrete leaf; returns the path segments.
leafStateOf(def, path) The motion-bearing leaf state of a path, or null.
evaluateAnimatorPath(def, path, params, triggers, clipFinished?) One pure evaluation step over a path → { nextPath, consumedTriggers }.
STATE_PATH_SEP The path separator, '/'.

The animator controller editor with a Layers list (Upper body over Base) and the parameters panel

The animator controller of the third-person example. Layers (top right) stack on the base layer, each with its own weight and mask; Parameters below drive the transitions.

One state machine can say a character is running or waving, never both. A controller can carry layers over its base machine: each is a machine of its own, with its own clock, transitions and active state, and the entity ends up as the whole stack, written once. Layers compose in order, so swapping two is a different character.

// in the .esanimator, beside "states"
"layers": [{
"name": "Upper body",
"weight": 1, // 0 leaves the layers below alone, 1 states this layer whole
"blend": "override", // or "additive": add what the clip departs from its first frame
"mask": { "paths": ["Spine"] }, // joints this layer may write, by childPath; each stands for its subtree
"initialState": "Rest",
"states": [ /* ... */ ]
}]

A mask is a set of the same childPaths a clip already uses to name what it animates. No mask writes the whole rig; an empty paths list writes nothing. In the editor a layer’s Restrict to a mask lists the paths as an array, as Unreal’s Details lists a blend mask’s branches: each element is a joint picked from the rig in the open scene that plays the controller, and brings its whole branch; with no such rig, the paths are typed. Root motion belongs to the base layer alone, and a trigger is one event every layer is told about. The editor’s layer rail picks which machine the canvas edits.

A controller’s ik list reaches for things the clips did not know about: two-bone puts a limb’s tip (tip, a joint by childPath) on a target, bending towards an optional pole; look-at turns a joint until its own axis points at the target. Each has a weight, and a float parameter can fade it. IK belongs to the controller, not to a layer, and runs once on the stack’s answer.

foot-plant keeps a foot on the ground. It takes a tip and no target: it casts down through 3D physics from where the clip put the foot, and bends the leg so the foot lands on what it finds, keeping any lift the clip gave it, so a walk still walks. pelvis names a joint lowered so the leg can reach the lower foot; align: false keeps the foot from lying along the slope; reach is how far to look, smooth the seconds to settle on a new height, and layers the physics layers that count as ground. Set layers when the character has a collider of its own, or the ray stops on it. The rig should stand with its feet at height 0 and its root on the ground. Foot-plants run before the other constraints, and with no physics in the game they leave the clip alone.

Avatars. A clip names joints by whatever the exporter called them, so two characters rigged by two people share no clip. An .esavatar (Add → New Avatar) is the rig’s own translation of those names and records its bind pose; a controller’s avatar names the avatar its clips were authored against, and the Animator’s avatar field takes the rig’s own. One controller then drives rigs with different bone names and different bind poses, and root motion is scaled to the distance each rig would travel.

A clip can name the moments inside it. A customEvent track in an .estimeline carries { time, name, payload }, and the animator reports each one on the frame whose step crossed it — never the frame that landed on it, which a fixed timestep does not do. They arrive on the AnimatorEvent bus:

import {
defineSystem, EventReader, GetWorld, Res,
AnimatorEvent, Particle, resolveChildEntity,
} from 'esengine';
const footsteps = defineSystem(
[EventReader(AnimatorEvent), GetWorld(), Res(Particle)],
(events, world, particles) => {
for (const event of events) {
if (event.name !== 'footstep') continue;
const dust = resolveChildEntity(world, event.entity, 'FootDust');
if (dust !== null) particles.play(dust);
}
},
{ name: 'FootstepSystem' },
);
Field Description
entity The animated entity — who this happened to.
name The event’s name as the clip declared it.
value Its numeric payload (payload.value); 0 when the clip states none.
text Its string payload (payload.text); empty when the clip states none.

What the animator promises:

  • An event fires on the interval (previous, current] a step covered, so a long frame never steps over one and never reports one twice.
  • A loop wrap is two intervals — the tail of the lap, then the head of the next — so an event near either end fires exactly once per lap.
  • Several events in one step fire in the order the clip declares them.
  • During a crossfade only the state being entered reports events. The one fading out keeps its clock and says nothing, so an attack cancelled into a dodge does not go on landing its hit.

The animator calls into no particle system, no audio and no gameplay: it states the event, and whoever owns those things answers it.

Some beats are stretches, not moments: an attack’s active frames, the part of a swing a combo can be chained in, a dodge’s invulnerability. Give a customEvent a duration (seconds of clip time) and it is a window, open over [time, time + duration). It is still posted once on the bus where it opens; what it adds is a state gameplay can ask about every frame:

{ "time": 0.18, "duration": 0.12, "name": "attack-active", "payload": {} }
const animator = app.getResource(AnimatorController);
const active = animator.openWindow(entity, 'attack-active'); // null when shut
for (const w of animator.windowsOf(entity)) console.log(w.name, w.id);
  • A window is reported for every frame whose step reached any part of it, so one shorter than a frame is still open on the frame that passed over it. A step that only reaches its closing edge does not open it.
  • Only the state being played holds windows, as with events: leave the clip while a window is open, a crossfade included, and it is shut on that frame. Gameplay that waits for an “end” event an interrupted clip never reaches cannot be stuck.
  • Each opening has its own id, kept while it stays open. Two attacks back to back whose windows touch are two openings, and so is each lap of a looping clip.

A state’s playback speed can follow a float parameter, so a run clip keeps pace with a character’s speed:

{
"name": "Run",
"motion": { "kind": "timeline", "clip": "run.estimeline", "loop": true },
"speedParameter": "MoveSpeed",
"transitions": []
}

The state’s clock advances by dt × MoveSpeed: 2 plays twice as fast, 0 holds the pose. It scales whatever the motion is, a sprite clip, a timeline or a blend, because it is the state’s clock that is scaled. A parameter that is not there plays at the normal rate.

A clip that animates the entity it is played on is not posing a skeleton — it is saying where the character travels. A state declares that:

{
"name": "Dodge",
"motion": { "kind": "timeline", "clip": "dodge.estimeline", "loop": false },
"rootMotion": true,
"transitions": [{ "to": "Idle", "conditions": [], "hasExitTime": true }]
}

The animator then keeps that root track’s position and rotation out of the pose — the clip never moves the entity — and publishes what it asked for on the entity’s AnimatorRootMotion component:

Field Description
enabled Authoring: whether the request is published at all.
active A state declaring root motion is driving this frame.
deltaPosition The displacement asked for, in world space.
deltaRotation The turn asked for, in the character’s own frame.
deltaTime The seconds the two deltas cover.

deltaTime comes with the deltas because the animator runs on the frame clock while a character controller usually steps on a fixed one: form a rate from the pair. A consumer that simply added the displacement would move twice on a frame with two fixed steps and not at all on a frame with none.

Read active rather than “is the delta non-zero” — a dodge has a still moment in the middle, and the stick must not take it back there. Without an AnimatorRootMotion component the state still refuses to pose the character’s own transform; the clip simply plays on the spot.

  • Spine Animation — skeletal animation, also driveable by the state machine.
  • Timeline — keyframed cutscenes and sequenced events.
  • Camera — tween CameraOrthoSize for smooth zooms.