Skip to content

luxe: system/anim.modifier


import "luxe: system/anim.modifier" for Anim

Anim is an animation player attached to an entity.

It plays animations from animation assets or ones created from code. Animations can target the entity Anim is attached to, but can target any entity. For example, a level cutscene could be played back from one entity, but it drives several other entities. From assets like scenes and prototypes, Anim provides an autoplay list, for playing when loaded.

You can play multiple animations at the same time, for example, the player might have a walk animation playing and you play a glowing animation on top.

Anim supports curve, linear and discrete driven animations and is expanded on by World Systems that provide animation tracks.

Anim.create(entity : Entity) : unknown

Attach an Anim modifier to entity.

var entity = Entity.create(world)
Anim.create(entity)

Anim.destroy(entity : Entity) : None

Detach and destroy the Anim attached to entity.

Anim.destroy(entity)

Anim.has(entity : Entity) : Bool

Returns whether entity has an Anim modifier attached.

if(Anim.has(entity)) {
Log.print("found anim")
}

Anim.valid(entity : Entity, anim : Anim) : Bool

Returns whether the Anim instance is valid for the Anim attached to entity.

var anim = Anim.play(entity, "player/idle")
if(!Anim.valid(entity, anim)) {
Log.print("oh no!")
}

Anim.get_source_id(entity : Entity, anim : Anim) : ID

Returns the ID of the animation asset that the Anim instance was played from, if known, by asking the Anim attached to entity. Returns null if not.

var anim = Anim.play(entity, "player/idle")
var source_id = Anim.get_source_id(entity, anim)
Log.print(Strings.get(source_id)) //expect: "player/idle"

Anim.get_state(entity : Entity, anim : Anim) : AnimState

Return the animation state of the Anim instance, by asking the Anim attached to entity.

var anim = Anim.play(entity, "player/idle")
var state = Anim.get_state(entity, anim)
if(state == AnimState.playing) {
Anim.stop(entity, anim)
}

Anim.get_active_anims(entity : Entity) : List

Returns a list of Anim instances that are active on the Anim attached to entity.

var active = Anim.get_active_anims(entity)
for(anim in active) {
var state = Anim.get_state(entity, anim)
Log.print(AnimState.name(state));
}

Anim.play(entity : Entity, anim_lx : ID, time_offset : Num) : Anim

Play the animation asset anim_lx on the Anim attached to entity. The time_offset is a time in seconds to begin playback from. For example, you might pause an animation and hold onto the animation time when it was paused. Then when resuming, you can play from the new time. Returns the newly started Anim instance.

var anim = Anim.play(entity, "player/idle", 0.5)

Anim.play_block(entity : Entity, anim_block : Block, anim_instance : BlockInstance, time_offset : Num, force_parse : Bool) : Anim

Play the animation stored in a block instance on the Anim attached to entity. This way you can play animations that are not in the asset system.

Anim.blend(entity : Entity, anim_lx : ID, blend_time : Num, time_offset : Num) : Anim

Play the animation asset anim_lx on the Anim attached to entity with a blend fade time. The time_offset is a time in seconds to begin playback from. The blend_time is handled by some tracks, not all. Returns the newly started Anim instance.

//fade in the animation over 0.6 seconds
var anim = Anim.blend(entity, "player/idle", 0.6)

Anim.play(entity : Entity, anim_lx : ID) : Anim

Play the animation asset anim_lx on the Anim attached to entity. Plays from the beginning. Returns the newly started Anim instance.

var anim = Anim.play(entity, "player/idle")

Anim.blend(entity : Entity, anim_lx : ID, blend_time : Num) : Anim

Play the animation asset anim_lx on the Anim attached to entity with a blend fade time. Plays from the beginning. Blend time is handled by some tracks, not all. Returns the newly started Anim instance.

//fade in the animation over 0.6 seconds
var anim = Anim.blend(entity, "player/idle", 0.6)

Anim.play_only(entity : Entity, anim_lx : ID, time_offset : Num) : Anim

Play the animation asset anim_lx on the Anim attached to entity, stopping all other active anims, and only playing this one. The time_offset is a time in seconds to begin playback from. Returns the newly started Anim instance.

var anim = Anim.play_only(entity, "player/idle", 0.5)

Anim.play_only(entity : Entity, anim_lx : ID) : Anim

Play the animation asset anim_lx on the Anim attached to entity, stopping all other active anims, and only playing this one. Returns the newly started Anim instance.

var anim = Anim.play_only(entity, "player/idle")

Anim.stop(entity : Entity, anim : Anim, reset : Bool) : None

Stop the Anim instance if playing on the Anim attached to entity.

If reset is true, the state of anything that was being animated by this Anim instance, will be reset to what it was before it was played. For example, if your animation is changing the transform position, it will revert back to the position at the time the animation was played.

var anim = Anim.play(entity, "player/idle")
Anim.stop(entity, anim, true)

Anim.stop(entity : Entity, anim : Anim) : None

Stop the Anim instance if playing on the Anim attached to entity. State is not reset (see Anim.stop(entity, anim, reset)).

var anim = Anim.play(entity, "player/idle")
Anim.stop(entity, anim)

Anim.stop_all(entity : Entity, reset : Bool) : None

Stop all active Anim instances playing on the Anim attached to entity. If reset is true, state will be reset to the state before the animation started (see Anim.stop(entity, anim, reset)).

var anim = Anim.play(entity, "player/idle")
Anim.stop_all(entity, true)

Anim.stop_all(entity : Entity) : None

Stop all active Anim instances playing on the Anim attached to entity. State is not reset (see Anim.stop(entity, anim, reset)).

var anim = Anim.play(entity, "player/idle")
Anim.stop_all(entity)

Anim.create_track(entity : Entity, anim : Anim, track_id : Any, track_type : Any) : unknown

no docs found

Anim.has_track(entity : Entity, anim : Anim, track_id : Any) : unknown

no docs found

Anim.track_set_range(entity : Entity, anim : Anim, track_id : Any, min : Any, max : Any) : unknown

no docs found

Anim.track_get_range(entity : Entity, anim : Anim, track_id : Any) : unknown

no docs found

Anim.track_set(entity : Entity, anim : Anim, track_id : Any, property : Any, value : Any) : unknown

no docs found

Anim.track_set_channel(entity : Entity, anim : Anim, track_id : Any, channel_id : Any, channel_idx : Any, interp : Any, keys : Any) : unknown

no docs found

Anim.set_play_count(entity : Entity, anim : Anim, play_count : Num) : None

Set the amount of times to play the Anim instance on the Anim attached to entity. The play_count value can be 0, which will loop forever.

//play 3 times and then end
var anim = Anim.play(entity, "player/idle")
Anim.set_play_count(entity, anim, 3)

Anim.set_rate(entity : Entity, anim : Anim, rate : Num) : None

Set the playback rate of the Anim instance on the Anim attached to entity. The rate of 1 is the default speed. 0.5 is half speed, and 2 is twice as fast.

var anim = Anim.play(entity, "player/idle")
Anim.set_rate(entity, anim, 0.5)

Anim.set_start(entity : Entity, anim : Anim, start : Num) : None

Set the start marker of the Anim instance on the Anim attached to entity. note This API is WIP.

Anim.set_start(entity, anim, 0)

Anim.set_end(entity : Entity, anim : Anim, end : Num) : None

Set the end marker of the Anim instance on the Anim attached to entity. note This API is WIP.

Anim.set_end(entity, anim, 1)

Anim.set_interval_time(entity : Entity, anim : Anim, time : Num) : None

Set the current playback time of the Anim instance on the Anim attached to entity. note This API is WIP.

Anim.set_interval_time(entity, anim, 0.5)

Anim.set_persist(entity : Entity, anim : Anim, persist : Bool) : None

Set an Anim instance to persist after it has ended, making it stick around until stopped manually or the Anim modifier it is on is destroyed. Only useful for niche cases like in the editor.

Anim.get_play_count(entity : Entity, anim : Anim) : Num

Return the play count of the Anim instance on the Anim attached to entity.

var play_count = Anim.get_play_count(entity, anim)

Anim.get_rate(entity : Entity, anim : Anim) : Num

Return the rate of playback of the Anim instance on the Anim attached to entity.

var play_count = Anim.get_play_count(entity, anim)

Anim.get_duration(entity : Entity, anim : Anim) : Num

Return the duration of the Anim instance on the Anim attached to entity.

var play_count = Anim.get_play_count(entity, anim)

Anim.get_start(entity : Entity, anim : Anim) : Num

Return the start marker of the Anim instance on the Anim attached to entity.

var play_count = Anim.get_play_count(entity, anim)

Anim.get_end(entity : Entity, anim : Anim) : Num

Return the end marker of the Anim instance on the Anim attached to entity.

var play_count = Anim.get_play_count(entity, anim)

Anim.get_interval_time(entity : Entity, anim : Anim) : Num

Return the current playback time of the Anim instance on the Anim attached to entity. note This API is WIP.

var play_count = Anim.get_play_count(entity, anim)

Anim.on_event(entity : Entity, anim : Anim, fn : Fn) : None

no docs found

import "luxe: system/anim.modifier" for AnimEvent

no docs found

AnimEvent.start : unknown

An event fired when an animation started playing.

AnimEvent.tick : unknown

An event fired when an animation is updated, but only if the track is set to emit the event.

AnimEvent.complete : unknown

An event fired when an animation is stopped or done playing.

AnimEvent.name(value : AnimEvent) : unknown

no docs found

import "luxe: system/anim.modifier" for AnimInterpolation

An enum for types of interpolation in animation tracks.

AnimInterpolation.unknown : unknown

An invalid or unknown value.

if(value == AnimInterpolation.unknown) {
Log.print("unknown interpolation type!")
}

AnimInterpolation.curve : unknown

The animation values between keys will be interpolated according to the curve defined by the keys themselves.

if(value == AnimInterpolation.curve) {
Log.print("curve")
}

AnimInterpolation.linear : unknown

The animation values between keys will be interpolated linearly. For example if your keys were { time=0 value=0 } and { time=1 value=4 }, at the time of 0.5 the value would be 2, half of the next key.

if(value == AnimInterpolation.linear) {
Log.print("linear")
}

AnimInterpolation.discrete : unknown

The animation values between keys would not be interpolated, they would jump from one value to the next. For example if your keys were { time=0 value=0 } and { time=1 value=3 }, with discrete the value at time 0.5 is still 0 (instead of 1.5 with linear). It will only change to 3 when the next key is reached.

if(value == AnimInterpolation.discrete) {
Log.print("discrete")
}

AnimInterpolation.name(value : AnimInterpolation) : String

Convert an AnimInterpolation value to a string.

var type = AnimInterpolation.linear
var name = AnimInterpolation.name(type)
Log.print("type is %(name)") //expect: "linear"

AnimInterpolation.from_string(value : String) : AnimInterpolation

Get the AnimInterpolation value to a name.

var type = AnimInterpolation.from_string("discrete")
Log.print("discrete is value %(type)") //expect: "3", the internal value
import "luxe: system/anim.modifier" for AnimInterval

no docs found

AnimInterval.create(world : Any, duration : Any, rate : Any) : unknown

no docs found

AnimInterval.create(world : Any, duration : Any) : unknown

no docs found

AnimInterval.time(world : Any, anim : Any) : unknown

no docs found

AnimInterval.set_time(world : Any, anim : Any, time : Any) : unknown

no docs found

AnimInterval.set_now(world : Any, anim : Any, offset : Any) : unknown

no docs found

AnimInterval.set_now(world : Any, anim : Any) : unknown

no docs found

AnimInterval.set_play_count(world : Any, anim : Any, count : Any) : unknown

no docs found

AnimInterval.set_clock(world : Any, anim : Any, clock : Any) : unknown

no docs found

AnimInterval.set_rate(world : Any, anim : Any, rate : Any) : unknown

no docs found

AnimInterval.set_duration(world : Any, anim : Any, duration : Any) : unknown

no docs found

AnimInterval.set_start(world : Any, anim : Any, start : Any) : unknown

no docs found

AnimInterval.set_end(world : Any, anim : Any, end : Any) : unknown

no docs found

AnimInterval.get_now(world : Any, anim : Any) : unknown

no docs found

AnimInterval.get_play_count(world : Any, anim : Any) : unknown

no docs found

AnimInterval.get_clock(world : Any, anim : Any) : unknown

no docs found

AnimInterval.get_rate(world : Any, anim : Any) : unknown

no docs found

AnimInterval.get_duration(world : Any, anim : Any) : unknown

no docs found

AnimInterval.get_start(world : Any, anim : Any) : unknown

no docs found

AnimInterval.get_end(world : Any, anim : Any) : unknown

no docs found

import "luxe: system/anim.modifier" for AnimState

An enum for the state of an Anim instance.

AnimState.inactive : Num

The animation is inactive. :todo: This may be obsolete.

var state = Anim.get_state(entity, anim)
if(state == AnimState.inactive) {
Log.print("anim is inactive")
}

AnimState.playing : Num

The animation is active and is playing.

var state = Anim.get_state(entity, anim)
if(state == AnimState.playing) {
Log.print("anim is playing")
}

AnimState.ending : Num

The animation is ending, and will be marked complete next update.

var state = Anim.get_state(entity, anim)
if(state == AnimState.ending) {
Log.print("anim is ending")
}

AnimState.complete : Num

The animation has ended and is complete.

var state = Anim.get_state(entity, anim)
if(state == AnimState.complete) {
Log.print("anim is complete")
}

AnimState.name(value : Num) : String

Convert an AnimState value to a string.

var type = AnimState.ending
var name = AnimState.name(type)
Log.print("type is %(name)") //expect: "ending"

AnimState.from_string(value : String) : Num

Convert a string to an enum value.

var state = AnimState.from_string("ending")
var same = state == AnimState.ending //true
import "luxe: system/anim.modifier" for AnimUI

no docs found

AnimUI.make_field(state : UIBlockState, name : String, type : BlockFieldType, view : ValueView) : unknown

no docs found

AnimUI.refresh(container : Any, anim_block : Any, state : Any) : unknown

no docs found

import "luxe: system/anim.modifier" for Data

no docs found

var play : List = []
var internal : Object = null
var show_editor : Num = 0
import "luxe: system/anim.modifier" for System

no docs found

System.new(world : World) : System

no docs found

System.editor_change(entity : Entity, change : ModifierChange) : unknown

no docs found