AnimationPlayer

package
v0.0.0-...-fa94a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

An animation player is used for general-purpose playback of animations. It contains a dictionary of AnimationLibrary resources and custom blend times between animation transitions.

Some methods and properties use a single key to reference an animation directly. These keys are formatted as the key for the library, followed by a forward slash, then the key for the animation within the library, for example "movement/run". If the library's key is an empty string (known as the default library), the forward slash is omitted, being the same key used by the library.

AnimationPlayer is better-suited than Tween for more complex animations, for example ones with non-trivial timings. It can also be used over Tween if the animation track editor is more convenient than doing it in code.

Updating the target properties of animations occurs at the process frame.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type AnimationMethodCallMode

type AnimationMethodCallMode int //gd:AnimationPlayer.AnimationMethodCallMode
const (
	AnimationMethodCallDeferred  AnimationMethodCallMode = 0
	AnimationMethodCallImmediate AnimationMethodCallMode = 1
)

type AnimationProcessCallback

type AnimationProcessCallback int //gd:AnimationPlayer.AnimationProcessCallback
const (
	AnimationProcessPhysics AnimationProcessCallback = 0
	AnimationProcessIdle    AnimationProcessCallback = 1
	AnimationProcessManual  AnimationProcessCallback = 2
)

type Any

type Any interface {
	gd.IsClass
	AsAnimationPlayer() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsAnimationMixer

func (self *Extension[T]) AsAnimationMixer() AnimationMixer.Instance

func (*Extension[T]) AsAnimationPlayer

func (self *Extension[T]) AsAnimationPlayer() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.AnimationPlayer

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AnimationGetNext

func (self Instance) AnimationGetNext(animation_from string) string

Returns the key of the animation which is queued to play after the 'animation_from' animation.

func (Instance) AnimationSetNext

func (self Instance) AnimationSetNext(animation_from string, animation_to string)

Triggers the 'animation_to' animation when the 'animation_from' animation completes.

func (Instance) AsAnimationMixer

func (self Instance) AsAnimationMixer() AnimationMixer.Instance

func (Instance) AsAnimationPlayer

func (self Instance) AsAnimationPlayer() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AssignedAnimation

func (self Instance) AssignedAnimation() string

func (Instance) Autoplay

func (self Instance) Autoplay() string

func (Instance) ClearQueue

func (self Instance) ClearQueue()

Clears all queued, unplayed animations.

func (Instance) CurrentAnimation

func (self Instance) CurrentAnimation() string

func (Instance) CurrentAnimationLength

func (self Instance) CurrentAnimationLength() Float.X

func (Instance) CurrentAnimationPosition

func (self Instance) CurrentAnimationPosition() Float.X

func (Instance) GetBlendTime

func (self Instance) GetBlendTime(animation_from string, animation_to string) Float.X

Returns the blend time (in seconds) between two animations, referenced by their keys.

func (Instance) GetMethodCallMode

func (self Instance) GetMethodCallMode() AnimationMethodCallMode

Returns the call mode used for "Call Method" tracks.

func (Instance) GetPlayingSpeed

func (self Instance) GetPlayingSpeed() Float.X

Returns the actual playing speed of current animation or 0 if not playing. This speed is the SpeedScale property multiplied by custom_speed argument specified when calling the Play method.

Returns a negative value if the current animation is playing backwards.

func (Instance) GetProcessCallback

func (self Instance) GetProcessCallback() AnimationProcessCallback

Returns the process notification in which to update animations.

func (Instance) GetQueue

func (self Instance) GetQueue() []string

Returns a list of the animation keys that are currently queued to play.

func (Instance) GetRoot

func (self Instance) GetRoot() string

Returns the node which node path references will travel from.

func (Instance) GetSectionEndTime

func (self Instance) GetSectionEndTime() Float.X

Returns the end time of the section currently being played.

func (Instance) GetSectionStartTime

func (self Instance) GetSectionStartTime() Float.X

Returns the start time of the section currently being played.

func (Instance) HasSection

func (self Instance) HasSection() bool

Returns true if an animation is currently playing with a section.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsPlaying

func (self Instance) IsPlaying() bool

Returns true if an animation is currently playing (even if SpeedScale and/or custom_speed are 0).

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) MovieQuitOnFinish

func (self Instance) MovieQuitOnFinish() bool

func (Instance) OnAnimationChanged

func (self Instance) OnAnimationChanged(cb func(old_name string, new_name string), flags ...Signal.Flags)

func (Instance) OnCurrentAnimationChanged

func (self Instance) OnCurrentAnimationChanged(cb func(name string), flags ...Signal.Flags)

func (Instance) Pause

func (self Instance) Pause()

Pauses the currently playing animation. The CurrentAnimationPosition will be kept and calling Play or PlayBackwards without arguments or with the same animation name as AssignedAnimation will resume the animation.

See also Stop.

func (Instance) Play

func (self Instance) Play()

Plays the animation with key 'name'. Custom blend times and speed can be set.

The 'from_end' option only affects when switching to a new animation track, or if the same track but at the start or end. It does not affect resuming playback that was paused in the middle of an animation. If 'custom_speed' is negative and 'from_end' is true, the animation will play backwards (which is equivalent to calling PlayBackwards).

The AnimationPlayer keeps track of its current or last played animation with AssignedAnimation. If this method is called with that same animation 'name', or with no 'name' parameter, the assigned animation will resume playing if it was paused.

Note: The animation will be updated the next time the AnimationPlayer is processed. If other variables are updated at the same time this is called, they may be updated too early. To perform the update immediately, call advance(0).

func (Instance) PlayBackwards

func (self Instance) PlayBackwards()

Plays the animation with key 'name' in reverse.

This method is a shorthand for Play with custom_speed = -1.0 and from_end = true, so see its description for more information.

func (Instance) PlayNamed

func (self Instance) PlayNamed(anim_name string)

func (Instance) PlaySection

func (self Instance) PlaySection()

Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time'. See also Play.

Setting 'start_time' to a value outside the range of the animation means the start of the animation will be used instead, and setting 'end_time' to a value outside the range of the animation means the end of the animation will be used instead. 'start_time' cannot be equal to 'end_time'.

func (Instance) PlaySectionBackwards

func (self Instance) PlaySectionBackwards()

Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time' in reverse.

This method is a shorthand for PlaySection with custom_speed = -1.0 and from_end = true, see its description for more information.

func (Instance) PlaySectionWithMarkers

func (self Instance) PlaySectionWithMarkers()

Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker'.

If the start marker is empty, the section starts from the beginning of the animation. If the end marker is empty, the section ends on the end of the animation. See also Play.

func (Instance) PlaySectionWithMarkersBackwards

func (self Instance) PlaySectionWithMarkersBackwards()

Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker' in reverse.

This method is a shorthand for PlaySectionWithMarkers with custom_speed = -1.0 and from_end = true, see its description for more information.

func (Instance) PlayWithCapture

func (self Instance) PlayWithCapture()

See also AnimationMixer.Capture.

You can use this method to use more detailed options for capture than those performed by PlaybackAutoCapture. When PlaybackAutoCapture is false, this method is almost the same as the following:

animationMixer.MoreArgs().Capture(name("run"), duration(0.2), Tween.TransitionType(0), Tween.EaseType(0))
animationPlayer.MoreArgs().PlayWithCapture(name("run"), duration(0.5), custom_blend(1), custom_speed(1), from_end(false), Tween.TransitionType(0), Tween.EaseType(0))

If 'name' is blank, it specifies AssignedAnimation.

If 'duration' is a negative value, the duration is set to the interval between the current position and the first key, when 'from_end' is true, uses the interval between the current position and the last key instead.

Note: The 'duration' takes SpeedScale into account, but 'custom_speed' does not, because the capture cache is interpolated with the blend result and the result may contain multiple animations.

func (Instance) PlaybackAutoCapture

func (self Instance) PlaybackAutoCapture() bool

func (Instance) PlaybackAutoCaptureDuration

func (self Instance) PlaybackAutoCaptureDuration() Float.X

func (Instance) PlaybackAutoCaptureEaseType

func (self Instance) PlaybackAutoCaptureEaseType() Tween.EaseType

func (Instance) PlaybackAutoCaptureTransitionType

func (self Instance) PlaybackAutoCaptureTransitionType() Tween.TransitionType

func (Instance) PlaybackDefaultBlendTime

func (self Instance) PlaybackDefaultBlendTime() Float.X

func (Instance) Queue

func (self Instance) Queue(name string)

Queues an animation for playback once the current animation and all previously queued animations are done.

Note: If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.

func (Instance) ResetSection

func (self Instance) ResetSection()

Resets the current section. Does nothing if a section has not been set.

func (Instance) SeekTo

func (self Instance) SeekTo(seconds Float.X)

Seeks the animation to the 'seconds' point in time (in seconds). If 'update' is true, the animation updates too, otherwise it updates at process time. Events between the current frame and 'seconds' are skipped.

If 'update_only' is true, the method / audio / animation playback tracks will not be processed.

Note: Seeking to the end of the animation doesn't emit OnAnimationmixer.AnimationFinished. If you want to skip animation and emit the signal, use AnimationMixer.Advance.

func (Instance) SetAssignedAnimation

func (self Instance) SetAssignedAnimation(value string)

func (Instance) SetAutoplay

func (self Instance) SetAutoplay(value string)

func (Instance) SetBlendTime

func (self Instance) SetBlendTime(animation_from string, animation_to string, sec Float.X)

Specifies a blend time (in seconds) between two animations, referenced by their keys.

func (Instance) SetCurrentAnimation

func (self Instance) SetCurrentAnimation(value string)

func (Instance) SetMethodCallMode

func (self Instance) SetMethodCallMode(mode AnimationMethodCallMode)

Sets the call mode used for "Call Method" tracks.

func (Instance) SetMovieQuitOnFinish

func (self Instance) SetMovieQuitOnFinish(value bool)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPlaybackAutoCapture

func (self Instance) SetPlaybackAutoCapture(value bool)

func (Instance) SetPlaybackAutoCaptureDuration

func (self Instance) SetPlaybackAutoCaptureDuration(value Float.X)

func (Instance) SetPlaybackAutoCaptureEaseType

func (self Instance) SetPlaybackAutoCaptureEaseType(value Tween.EaseType)

func (Instance) SetPlaybackAutoCaptureTransitionType

func (self Instance) SetPlaybackAutoCaptureTransitionType(value Tween.TransitionType)

func (Instance) SetPlaybackDefaultBlendTime

func (self Instance) SetPlaybackDefaultBlendTime(value Float.X)

func (Instance) SetProcessCallback

func (self Instance) SetProcessCallback(mode AnimationProcessCallback)

Sets the process notification in which to update animations.

func (Instance) SetRoot

func (self Instance) SetRoot(path string)

Sets the node which node path references will travel from.

func (Instance) SetSection

func (self Instance) SetSection()

Changes the start and end times of the section being played. The current playback position will be clamped within the new section. See also PlaySection.

func (Instance) SetSectionWithMarkers

func (self Instance) SetSectionWithMarkers()

Changes the start and end markers of the section being played. The current playback position will be clamped within the new section. See also PlaySectionWithMarkers.

If the argument is empty, the section uses the beginning or end of the animation. If both are empty, it means that the section is not set.

func (Instance) SetSpeedScale

func (self Instance) SetSpeedScale(value Float.X)

func (Instance) SpeedScale

func (self Instance) SpeedScale() Float.X

func (Instance) Stop

func (self Instance) Stop()

Stops the currently playing animation. The animation position is reset to 0 and the custom_speed is reset to 1.0. See also Pause.

If 'keep_state' is true, the animation state is not updated visually.

Note: The method / audio / animation playback tracks will not be processed by this method.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type MoreArgs

type MoreArgs [1]gdclass.AnimationPlayer

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) Play

func (self MoreArgs) Play(name string, custom_blend Float.X, custom_speed Float.X, from_end bool)

Plays the animation with key 'name'. Custom blend times and speed can be set.

The 'from_end' option only affects when switching to a new animation track, or if the same track but at the start or end. It does not affect resuming playback that was paused in the middle of an animation. If 'custom_speed' is negative and 'from_end' is true, the animation will play backwards (which is equivalent to calling PlayBackwards).

The AnimationPlayer keeps track of its current or last played animation with AssignedAnimation. If this method is called with that same animation 'name', or with no 'name' parameter, the assigned animation will resume playing if it was paused.

Note: The animation will be updated the next time the AnimationPlayer is processed. If other variables are updated at the same time this is called, they may be updated too early. To perform the update immediately, call advance(0).

func (MoreArgs) PlayBackwards

func (self MoreArgs) PlayBackwards(name string, custom_blend Float.X)

Plays the animation with key 'name' in reverse.

This method is a shorthand for Play with custom_speed = -1.0 and from_end = true, so see its description for more information.

func (MoreArgs) PlaySection

func (self MoreArgs) PlaySection(name string, start_time Float.X, end_time Float.X, custom_blend Float.X, custom_speed Float.X, from_end bool)

Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time'. See also Play.

Setting 'start_time' to a value outside the range of the animation means the start of the animation will be used instead, and setting 'end_time' to a value outside the range of the animation means the end of the animation will be used instead. 'start_time' cannot be equal to 'end_time'.

func (MoreArgs) PlaySectionBackwards

func (self MoreArgs) PlaySectionBackwards(name string, start_time Float.X, end_time Float.X, custom_blend Float.X)

Plays the animation with key 'name' and the section starting from 'start_time' and ending on 'end_time' in reverse.

This method is a shorthand for PlaySection with custom_speed = -1.0 and from_end = true, see its description for more information.

func (MoreArgs) PlaySectionWithMarkers

func (self MoreArgs) PlaySectionWithMarkers(name string, start_marker string, end_marker string, custom_blend Float.X, custom_speed Float.X, from_end bool)

Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker'.

If the start marker is empty, the section starts from the beginning of the animation. If the end marker is empty, the section ends on the end of the animation. See also Play.

func (MoreArgs) PlaySectionWithMarkersBackwards

func (self MoreArgs) PlaySectionWithMarkersBackwards(name string, start_marker string, end_marker string, custom_blend Float.X)

Plays the animation with key 'name' and the section starting from 'start_marker' and ending on 'end_marker' in reverse.

This method is a shorthand for PlaySectionWithMarkers with custom_speed = -1.0 and from_end = true, see its description for more information.

func (MoreArgs) PlayWithCapture

func (self MoreArgs) PlayWithCapture(name string, duration Float.X, custom_blend Float.X, custom_speed Float.X, from_end bool, trans_type Tween.TransitionType, ease_type Tween.EaseType)

See also AnimationMixer.Capture.

You can use this method to use more detailed options for capture than those performed by PlaybackAutoCapture. When PlaybackAutoCapture is false, this method is almost the same as the following:

animationMixer.MoreArgs().Capture(name("run"), duration(0.2), Tween.TransitionType(0), Tween.EaseType(0))
animationPlayer.MoreArgs().PlayWithCapture(name("run"), duration(0.5), custom_blend(1), custom_speed(1), from_end(false), Tween.TransitionType(0), Tween.EaseType(0))

If 'name' is blank, it specifies AssignedAnimation.

If 'duration' is a negative value, the duration is set to the interval between the current position and the first key, when 'from_end' is true, uses the interval between the current position and the last key instead.

Note: The 'duration' takes SpeedScale into account, but 'custom_speed' does not, because the capture cache is interpolated with the blend result and the result may contain multiple animations.

func (MoreArgs) SeekTo

func (self MoreArgs) SeekTo(seconds Float.X, update bool, update_only bool)

Seeks the animation to the 'seconds' point in time (in seconds). If 'update' is true, the animation updates too, otherwise it updates at process time. Events between the current frame and 'seconds' are skipped.

If 'update_only' is true, the method / audio / animation playback tracks will not be processed.

Note: Seeking to the end of the animation doesn't emit OnAnimationmixer.AnimationFinished. If you want to skip animation and emit the signal, use AnimationMixer.Advance.

func (MoreArgs) SetSection

func (self MoreArgs) SetSection(start_time Float.X, end_time Float.X)

Changes the start and end times of the section being played. The current playback position will be clamped within the new section. See also PlaySection.

func (MoreArgs) SetSectionWithMarkers

func (self MoreArgs) SetSectionWithMarkers(start_marker string, end_marker string)

Changes the start and end markers of the section being played. The current playback position will be clamped within the new section. See also PlaySectionWithMarkers.

If the argument is empty, the section uses the beginning or end of the animation. If both are empty, it means that the section is not set.

func (MoreArgs) Stop

func (self MoreArgs) Stop(keep_state bool)

Stops the currently playing animation. The animation position is reset to 0 and the custom_speed is reset to 1.0. See also Pause.

If 'keep_state' is true, the animation state is not updated visually.

Note: The method / audio / animation playback tracks will not be processed by this method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL