Aego Русский

Animation Player

Plays an animation clip on its node and the nodes below it: property tracks, sprite frames and events. Clip time, gameplay events and tracks other than the transform pose advance on fixed steps, so a replay gives the same result at any frame rate.

component animation.AnimationPlayer
On this page

Art Studio

Frame-by-frame animation Art Studio lessons

Try it

Play the run clip

The real Animation Player starts the eight-frame run clip at speed 0. Loop is set to once, so the last frame remains after playback.

Change Speed from 0 to 8 to play the clip quickly. Reset restores the first frame and speed 0.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene3 nodes
Runner
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000b00")tintColor#7dd3fcffsizeVec2[5, 5]filterenumnearest
Animation Player
clipAnimClipasset("ae900000000000000000000000000b10")playOnStartbooltruespeedfloat0loopenumoncetimeDomainenumgame
Floor
Transform
position[0, 3]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#4b5563ffsizeVec2[12, 0.2]
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue

Fields

NameTypeDefaultDescription
ClipAnimClipnone

Clip to play.

Play On Startbooltrue

Starts the clip when Play starts.

Speedfloat1

Playback speed: 1 is normal, 2 twice as fast; a negative speed plays backwards.

Loopenumclip

clip keeps the loop mode of the clip; once, loop and pingPong override it.

one of: clip, once, loop, pingPong
Time Domainenumgame

game follows game time and pauses with it; unscaled runs in real time while paused, for menus and other presentation.

one of: game, unscaled

Runtime state

Values the component has while the game runs. They are not saved with the scene.

NameTypeDefaultDescription
Timefloat0

Time inside the clip, in seconds.

Playingboolfalse

Whether the clip plays.

Cycleint0

Cycles of a looping clip so far.

Methods

Pause method

func (AnimationPlayer) Pause()

Holds the clip where it is.

Play method

func (AnimationPlayer) Play(clip AssetRef<anim>)

Starts a clip from its beginning on the next fixed step; nil plays the current clip again.

Example

node.Get<AnimationPlayer>().Play(Attack)

Resume method

func (AnimationPlayer) Resume()

Continues a paused clip.

Seek method

func (AnimationPlayer) Seek(time float)

Jumps to a time inside the clip on the next fixed step without firing the events in between.

SetSpeed method

func (AnimationPlayer) SetSpeed(speed float)

Changes the playback speed; a negative speed plays backwards.

Stop method

func (AnimationPlayer) Stop()

Ends the clip on the next fixed step: tracks with onEnd=restore get back the values they had before Play, Finished runs with cycle -1.

Signals

Event signal

signal Event(id int, payload float)

Runs when the clip reaches an event; anim.EventName(id) gives its name.

Finished signal

signal Finished(cycle int)

Runs when a clip that does not loop ends, with cycle 0, or after Stop, with cycle -1.

Script events

Scripts on a node with this component receive these events from the Animation module.