Skip to content

Animation

Per-clip animation state on nodes (node.animations[name]), blend layers, crossfade, events (including Blender timeline markers), drivers, and skeletal bone skinning. Animation data is loaded from .blend files via Resource.loadBlend.

Obtained from node.animations[name]. Each named action from Blender appears as an entry. .events is a Map (event name → AnimationEvent).

AnimationState.new() (typically obtained from node.animations[name]).

Method / propertyDescription
nameClip name (matches the Blender action name)
lengthDuration in seconds
currentTimeSeconds / currentTimeNormalizedCurrent playback position
getFloat(key) / setFloat(key, value)Float param by short key or full Blender data path
getInt(key) / setInt(key, value)Int param
getBool(key) / setBool(key, value)Bool param
MethodDescription
play(playOptions)Start playing with optional AnimationPlayOptions
pause()Pause the clip
resume()Resume from paused
eventsMap of event name → AnimationEvent
pendingEventsList of events that fired this frame; dispatch in update(dt)

Multiple clips can play simultaneously on the same node using layers. Each clip is assigned a layer index and a blend weight.

PropertyDescription
blendWeight / blendWeight=(value)This clip’s contribution (0–1, default 1.0)
crossfadeTo(playOptions)Smoothly crossfade from the current clip to a new one on the same layer
stopLayer(layer)Stop all clips on the given layer index
// Play a walk animation on layer 0
var walk = _node.animations["Walk"]
var opts = AnimationPlayOptions.new()
opts.loop = true
opts.layer = 0
walk.play(opts)
// Crossfade to run when sprinting
if (Input.key("shift")) {
var runOpts = AnimationPlayOptions.new()
runOpts.loop = true
runOpts.layer = 0
runOpts.crossfadeDuration = 0.2
walk.crossfadeTo(runOpts)
}
// In init():
var anim = _node.animations["Attack"]
anim.events["HitFrame"] = AnimationEvent.new()
anim.events["HitFrame"].addCallback(Fn.new { |e|
dealDamage()
})
// In update(dt):
for (event in anim.pendingEvents) {
if (anim.events.containsKey(event.name)) {
anim.events[event.name].invoke(event.name, event.time)
}
}

Named event slot (e.g. onStart, onEnd, or a Blender timeline marker). Create with AnimationEvent.new(), assign to animState.events["Name"], then register callbacks.

Method / propertyDescription
nameEvent name
timeTimestamp in seconds
addCallback(callback)Register a callback — Fn.new { |event| ... }
removeCallback(callback)Unregister a callback
invoke(name, time)Called when dispatching; invokes all registered callbacks

Options passed to play(playOptions) or crossfadeTo(playOptions) to configure how a clip starts.

AnimationPlayOptions.new()

PropertyDefaultDescription
reverse / reverse=(value)falsePlay in reverse
timeOffset / timeOffset=(value)0Start time offset in seconds
speed / speed=(value)1Playback speed multiplier
blendWeight / blendWeight=(value)1.0This clip’s blend contribution (0–1)
layer / layer=(value)0Layer index for crossfade grouping
crossfadeDuration / crossfadeDuration=(value)0Seconds to crossfade when replacing clips on the same layer
loop / loop=(value)falseWhether the clip loops
var opts = AnimationPlayOptions.new()
opts.loop = true
opts.speed = 1.5
opts.blendWeight = 0.8
opts.layer = 0
_anim.play(opts)

Reserved for future blend tree support.

AnimationBlendOptions.new()