Animation
Playing a clip
The durable way is the ClipPlayer component — attach it to the skinned body and it plays one clip through the AnimGraph (the names below are placeholders):
entity.find("hero").component.add("ClipPlayer", {
clip = asset.resolve("Walk", "animation"),
looping = true,
})
clip is an AssetRef<animation> (survives renames/moves); looping, speed, and
playing control playback. ClipPlayer waits for the body's skeleton to hydrate, so
it works on a body whose rigged mesh loads a few frames after the entity.
Testing a clip quickly
To eyeball a clip without authoring a component, use the animation toolbox:
tools.use("animation", "play", "A_Walk_F_Masc", "hero") -- play once, auto-cleanup
tools.use("animation", "play", "A_Idle_Standing_Masc", "hero", { offset = "5s" }) -- wait 5s, then play
tools.use("animation", "play", "A_Walk_FwdStrafeL_Masc", "hero", { loop = true, duration = 8 }) -- loop for 8s
From bash it is zero animation play A_Walk_F_Masc hero. The play tool resolves the clip by identity or name and the entity by id or name,
finds the SkinnedModel on it (or under it — the imported-character layout puts the
rigged mesh on a child), plays through the AnimGraph, and tears everything down when
the window ends. On a body that already animates it overrides for the window and the
body's own animation resumes untouched. Playback runs in play mode, like any
component-driven animation.
Faces: blend-shape tracks in a clip
A clip can carry blend-shape (morph target) weights beside its bones: one weight
track per shape, addressed by the shape's name. Importing a glTF keeps its
weights animation channels and importing an FBX keeps its blend-shape
DeformPercent curves, so a smile, a blink or a set of visemes arrives as a clip
like any other. skeleton.clipShapes(bytes) names the shapes a clip drives, the
clip's table form (skeleton.clipToTable) spells each track's path Weights
with target_bone naming the shape, and the Inspector lists them under the
clip.
A clip plays its tracks on whatever meshes of the body carry shapes of those
names, so one face clip plays on every body whose shapes share its names (a
standard expression name works too, where the avatar's expressions map names
the shape it stands for). ClipPlayer plays it on a skinned body or on a mesh
with blend shapes and no skin:
entity.find("face").component.add("ClipPlayer", {
clip = asset.resolve("Smile", "animation"),
looping = true,
})
The shapes ride the AnimGraph with the bones, so they blend wherever poses
blend: Mixers, BlendSpace2D and crossfades blend them, and a Layer takes the
overlay's shapes by a shape mask. A face clip over locomotion is a Layer masked
to the face:
local AnimGraph = require("@builtin::systems.anim.AnimGraph")
local bodyId = entity.find("hero").id
local smileRef = asset.resolve("Smile", "animation")
local g = AnimGraph.forEntity(bodyId)
local smile = AnimGraph.Clip.new(smileRef, g.layout, true, 1)
local face = AnimGraph.Layer.new(g.layout, g.output, smile,
AnimGraph.mask(g.layout, "face"), AnimGraph.shapeMask(g.layout, "face"))
g:setOutput(face)
face:setWeight(1) -- ramp it to fade the face in and out
AnimOverlay does the same from a component: its "head" and "upperBody"
regions take the clip's shapes as well as its bones, and "face" takes the
shapes alone. It plays its clip once, easing in and back out, on its input
control or when code calls trigger(), so a timer or a game event fires a
smile or a blink:
local smileRef = asset.resolve("Smile", "animation")
local body = entity.find("hero")
body.component.add("AnimOverlay", { clip = smileRef, region = "face" })
body.component.get("AnimOverlay"):trigger()
A shape no clip of the graph drives is left to whatever else sets
it (ecs.MorphWeights, an avatar's animator); when the clip that drove a shape
fades out, the shape returns to its rest weight: the weight the mesh held when
animation first read it, kept by name when another mesh takes its place
(AnimGraph.restShapes), so a graph built while an
expression weights a shape still returns it to where the face rests.
How a joint blends
A skinned vertex is placed by combining the joints that influence it, and there are two ways to combine them. The default averages the joint matrices — cheap, and what every rig gets unless it says otherwise. Where a joint twists far (a wrist rolling over, a shoulder, a spine), that average stops being a rotation and the limb pinches toward its own axis: the candy-wrapper. Switching that body to dual-quaternion skinning averages the joints' rigid motions instead and renormalises, so the cross-section survives the twist:
entity.find("hero").component.get("SkinnedModel").skinning = "dualQuaternion"
It is per body, so a character that twists hard can carry it while the rest of the cast stays on the cheaper default, and a rig at rest looks the same either way.
Checking what is animating, and why a body is not
animation.observe() reports every body the engine holds animation state for.
It reads the pose the engine measured landing on each armature, so it answers
whether a body is moving rather than whether something asked it to:
for _, body in animation.observe().bodies do
print(body.entity, body.animating, body.reason, body.matched .. "/" .. body.total)
end
animating is the engine's verdict. A ClipPlayer whose playing field is
true on a body whose bones never move reads animating = false here, with
reason naming the cause from a closed set: deactivated, noRiggedSkeleton,
noGraph, clipUnreadable, noOutputNode, retargetPending, retargetMatchedNoRoles,
stopped, finished, paused, poseNotApplied, poseUnchanged.
An editor sits paused until you press play, and a paused engine steps no
animator. Every body reads animating = false there, and reason separates the
ones that will move on resume — paused — from the ones that will not: a clip
that reaches none of the rig's bones still reports retargetMatchedNoRoles
while paused, because that is what is still wrong when the world starts again.
The clips, playheads and coverage a body was last driven with stay readable
across the pause.
Starting from one character
animation.whyStill is the one-line form, and it accepts a character root —
the rig lives on a skinned child, and the call resolves down to it:
local why, detail = animation.whyStill("hero")
if why then print("hero is not animating:", why, detail) end
When more than one animator is bound
body.driver is the animator the engine measured posing the body. A body can
carry two — a script animator and an AnimGraph component — and then
body.otherDrivers names the ones the report is not built from:
local body = animation.body("hero")
print(body.driver, table.concat(body.otherDrivers, ", "))
Each animator's poses are measured on their own, so the one whose pose the engine saw changing is the one the body's clips, playheads and coverage describe.
Is the clip reaching this rig
A clip is retargeted onto the body's rig when it binds, and the coverage that bake produced is the number that separates a working clip from a dead one:
local matched, total = animation.coverage("hero") -- 41, 50
for _, clip in animation.clips("hero") do
print(clip.name, clip.time, clip.matched .. "/" .. clip.total, #clip.unmatched)
end
A humanoid clip on a humanoid rig reaches most of the bones. A clip from an
unrelated rig reaches none — 0/50 — and the body stands in its rest pose while
the playhead advances exactly as it does on a working body. clip.unmatched
names the bones the clip leaves at rest, and retarget.plan(sourceRig, bodyRig)
(@builtin::modules.retarget) says why: driven lists the body's roles a bake
drives, and undriven maps each other role to its reason, such as a rig that
gives the role no anatomical frame or a source rig that maps no bone to it.
Measure the pose, not the playhead
body.pose is what the engine wrote onto the bones:
local pose = animation.body("hero").pose
print(pose.bonesWritten .. "/" .. pose.bonesRequested, pose.revision, pose.sinceChangedMs)
applies counts poses that reached the armature; revision counts the ones
whose values differed from the pose before. A body being animated advances both.
A body held in one pose advances applies alone, and sinceChangedMs grows.
pose.refusal names why a pose never landed at all — deactivated,
unsupportedStride, targetMissing, noSkeleton, noArmatureRoot,
armatureDrivenElsewhere.
armatureDrivenElsewhere is the one to know when two animators share a body: an
AnimGraph component and a ClipPlayer each rebuild the joint
matrices the renderer draws from their own graph, so a pose another animator
writes onto the same armature's bones is replaced before a frame is drawn from
it. The body then reads the animator that owns its skinning as its driver, and
names the other in otherDrivers.
From the shell, and on screen
tools.use("animation", "observe") condenses the same report to one line per
body, and /zero/runtime/animation serves it as a file:
local body = entity.find("hero")
vfs.read("/zero/runtime/animation") -- the whole observation
vfs.read("/zero/runtime/animation/bodies/" .. body.id) -- one body
The AnimDebug component in the Controllers library's characterController
package renders the same report as an on-screen HUD.
Attaching an item to an animated bone
An item made a child of a bone follows that bone's animation. On a humanoid
avatar, seat it on one of the standard attachment points through the avatar's
Humanoid component instead of naming the bone: the point is found on every
body from its skeleton's shape, whatever the rig calls its bones, and its frame
means the same on every body.
local h = entity.find("player").component.get("Humanoid")
local sword, hat = entity.find("sword"), entity.find("hat")
h:attach("rightGrip", sword.id) -- rides the right hand, blade along +Z out of the fist
h:attach("hat", hat.id) -- rides the head
guides { path: "topics/avatars" } has the 19 points, reading the body's eye
position, height and proportions, and refusing a body a game cannot use.
Going further
For blending, crossfades, and state machines, build on the AnimGraph directly
(@builtin::systems.anim.AnimGraph — layoutForEntity, Clip, Mixer,
BlendSpace2D, Layer). For full character movement — locomotion blending, turning,
jumps — the Controllers library's character controller (ZeroMind search Controllers)
wires clips to input and physics; install and inspect it rather than rebuilding that
from clips.