Documentation
¶
Overview ¶
Base class for graphics.gd/classdb/AnimationPlayer and graphics.gd/classdb/AnimationTree to manage animation lists. It also has general properties and methods for playback and blending.
After instantiating the playback information data within the extended class, the blending is processed by the graphics.gd/classdb/AnimationMixer.
Index ¶
- type Advanced
- type AnimationCallbackModeDiscrete
- type AnimationCallbackModeMethod
- type AnimationCallbackModeProcess
- type Any
- type Expanded
- type Extension
- type ID
- type Implementation
- type Instance
- func (self Instance) Active() bool
- func (self Instance) AddAnimationLibrary(name string, library AnimationLibrary.Instance) error
- func (self Instance) Advance(delta Float.X)
- func (self Instance) AsAnimationMixer() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AudioMaxPolyphony() int
- func (self Instance) CallbackModeDiscrete() AnimationCallbackModeDiscrete
- func (self Instance) CallbackModeMethod() AnimationCallbackModeMethod
- func (self Instance) CallbackModeProcess() AnimationCallbackModeProcess
- func (self Instance) Capture(name string, duration Float.X)
- func (self Instance) ClearCaches()
- func (self Instance) Deterministic() bool
- func (self Instance) FindAnimation(animation Animation.Instance) string
- func (self Instance) FindAnimationLibrary(animation Animation.Instance) string
- func (self Instance) GetAnimation(name string) Animation.Instance
- func (self Instance) GetAnimationLibrary(name string) AnimationLibrary.Instance
- func (self Instance) GetAnimationLibraryList() []string
- func (self Instance) GetAnimationList() []string
- func (self Instance) GetRootMotionPosition() Vector3.XYZ
- func (self Instance) GetRootMotionPositionAccumulator() Vector3.XYZ
- func (self Instance) GetRootMotionRotation() Quaternion.IJKX
- func (self Instance) GetRootMotionRotationAccumulator() Quaternion.IJKX
- func (self Instance) GetRootMotionScale() Vector3.XYZ
- func (self Instance) GetRootMotionScaleAccumulator() Vector3.XYZ
- func (self Instance) HasAnimation(name string) bool
- func (self Instance) HasAnimationLibrary(name string) bool
- func (self Instance) ID() ID
- func (self Instance) OnAnimationFinished(cb func(anim_name string), flags ...Signal.Flags)
- func (self Instance) OnAnimationLibrariesUpdated(cb func(), flags ...Signal.Flags)
- func (self Instance) OnAnimationListChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnAnimationStarted(cb func(anim_name string), flags ...Signal.Flags)
- func (self Instance) OnCachesCleared(cb func(), flags ...Signal.Flags)
- func (self Instance) OnMixerApplied(cb func(), flags ...Signal.Flags)
- func (self Instance) OnMixerUpdated(cb func(), flags ...Signal.Flags)
- func (self Instance) RemoveAnimationLibrary(name string)
- func (self Instance) RenameAnimationLibrary(name string, newname string)
- func (self Instance) ResetOnSave() bool
- func (self Instance) RootMotionLocal() bool
- func (self Instance) RootMotionTrack() string
- func (self Instance) RootNode() string
- func (self Instance) SetActive(value bool)
- func (self Instance) SetAudioMaxPolyphony(value int)
- func (self Instance) SetCallbackModeDiscrete(value AnimationCallbackModeDiscrete)
- func (self Instance) SetCallbackModeMethod(value AnimationCallbackModeMethod)
- func (self Instance) SetCallbackModeProcess(value AnimationCallbackModeProcess)
- func (self Instance) SetDeterministic(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetResetOnSave(value bool)
- func (self Instance) SetRootMotionLocal(value bool)
- func (self Instance) SetRootMotionTrack(value string)
- func (self Instance) SetRootNode(value string)
- func (self Instance) Virtual(name string) reflect.Value
- type Interface
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 AnimationCallbackModeDiscrete ¶
type AnimationCallbackModeDiscrete int //gd:AnimationMixer.AnimationCallbackModeDiscrete
const ( // An [Animation.UpdateDiscrete] track value takes precedence when blending [Animation.UpdateContinuous] or [Animation.UpdateCapture] track values and [Animation.UpdateDiscrete] track values. AnimationCallbackModeDiscreteDominant AnimationCallbackModeDiscrete = 0 // An [Animation.UpdateContinuous] or [Animation.UpdateCapture] track value takes precedence when blending the [Animation.UpdateContinuous] or [Animation.UpdateCapture] track values and the [Animation.UpdateDiscrete] track values. This is the default behavior for [graphics.gd/classdb/AnimationPlayer]. AnimationCallbackModeDiscreteRecessive AnimationCallbackModeDiscrete = 1 // Always treat the [Animation.UpdateDiscrete] track value as [Animation.UpdateContinuous] with [Animation.InterpolationNearest]. This is the default behavior for [graphics.gd/classdb/AnimationTree]. // // If a value track has un-interpolatable type key values, it is internally converted to use [AnimationCallbackModeDiscreteRecessive] with [Animation.UpdateDiscrete]. // // Un-interpolatable type list: // // - [@Globalscope.TypeNil] // // - [@Globalscope.TypeNodePath] // // - [@Globalscope.TypeRid] // // - [@Globalscope.TypeObject] // // - [@Globalscope.TypeCallable] // // - [@Globalscope.TypeSignal] // // - [@Globalscope.TypeDictionary] // // - [@Globalscope.TypePackedByteArray] // // [@Globalscope.TypeBool] and [@Globalscope.TypeInt] are treated as [@Globalscope.TypeFloat] during blending and rounded when the result is retrieved. // // It is same for arrays and vectors with them such as [@Globalscope.TypePackedInt32Array] or [@Globalscope.TypeVector2i], they are treated as [@Globalscope.TypePackedFloat32Array] or [@Globalscope.TypeVector2]. Also note that for arrays, the size is also interpolated. // // [@Globalscope.TypeString] and [@Globalscope.TypeStringName] are interpolated between character codes and lengths, but note that there is a difference in algorithm between interpolation between keys and interpolation by blending. AnimationCallbackModeDiscreteForceContinuous AnimationCallbackModeDiscrete = 2 )
type AnimationCallbackModeMethod ¶
type AnimationCallbackModeMethod int //gd:AnimationMixer.AnimationCallbackModeMethod
const ( // Batch method calls during the animation process, then do the calls after events are processed. This avoids bugs involving deleting nodes or modifying the AnimationPlayer while playing. AnimationCallbackModeMethodDeferred AnimationCallbackModeMethod = 0 // Make method calls immediately when reached in the animation. AnimationCallbackModeMethodImmediate AnimationCallbackModeMethod = 1 )
type AnimationCallbackModeProcess ¶
type AnimationCallbackModeProcess int //gd:AnimationMixer.AnimationCallbackModeProcess
const ( // Process animation during physics frames (see [Node.NotificationInternalPhysicsProcess]). This is especially useful when animating physics bodies. AnimationCallbackModeProcessPhysics AnimationCallbackModeProcess = 0 // Process animation during process frames (see [Node.NotificationInternalProcess]). AnimationCallbackModeProcessIdle AnimationCallbackModeProcess = 1 // Do not process animation. Use [Instance.Advance] to process the animation manually. AnimationCallbackModeProcessManual AnimationCallbackModeProcess = 2 )
type Expanded ¶
type Expanded [1]gdclass.AnimationMixer
func (Expanded) Capture ¶
func (self Expanded) Capture(name string, duration Float.X, trans_type Tween.TransitionType, ease_type Tween.EaseType)
If the animation track specified by 'name' has an option [Animation.UpdateCapture], stores current values of the objects indicated by the track path as a cache. If there is already a captured cache, the old cache is discarded.
After this it will interpolate with current animation blending result during the playback process for the time specified by 'duration', working like a crossfade.
You can specify 'trans_type' as the curve for the interpolation. For better results, it may be appropriate to specify [Tween.TransLinear] for cases where the first key of the track begins with a non-zero value or where the key value does not change, and [Tween.TransQuad] for cases where the key value changes linearly.
type Extension ¶
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]See Interface for methods that can be overridden by T.
func (*Extension[T]) AsAnimationMixer ¶
type 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.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
type Instance [1]gdclass.AnimationMixer
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 (Instance) AddAnimationLibrary ¶
func (self Instance) AddAnimationLibrary(name string, library AnimationLibrary.Instance) error
Adds 'library' to the animation player, under the key 'name'.
AnimationMixer has a global library by default with an empty string as key. For adding an animation to the global library:
var global_library = mixer.GetAnimationLibrary("") global_library.AddAnimation("animation_name", animation_resource)
func (Instance) AsAnimationMixer ¶
func (Instance) AudioMaxPolyphony ¶
func (Instance) CallbackModeDiscrete ¶
func (self Instance) CallbackModeDiscrete() AnimationCallbackModeDiscrete
func (Instance) CallbackModeMethod ¶
func (self Instance) CallbackModeMethod() AnimationCallbackModeMethod
func (Instance) CallbackModeProcess ¶
func (self Instance) CallbackModeProcess() AnimationCallbackModeProcess
func (Instance) Capture ¶
If the animation track specified by 'name' has an option [Animation.UpdateCapture], stores current values of the objects indicated by the track path as a cache. If there is already a captured cache, the old cache is discarded.
After this it will interpolate with current animation blending result during the playback process for the time specified by 'duration', working like a crossfade.
You can specify 'trans_type' as the curve for the interpolation. For better results, it may be appropriate to specify [Tween.TransLinear] for cases where the first key of the track begins with a non-zero value or where the key value does not change, and [Tween.TransQuad] for cases where the key value changes linearly.
func (Instance) ClearCaches ¶
func (self Instance) ClearCaches()
graphics.gd/classdb/AnimationMixer caches animated nodes. It may not notice if a node disappears; Instance.ClearCaches forces it to update the cache again.
func (Instance) Deterministic ¶
func (Instance) FindAnimation ¶
Returns the key of 'animation' or an empty string if not found.
func (Instance) FindAnimationLibrary ¶
Returns the key for the graphics.gd/classdb/AnimationLibrary that contains 'animation' or an empty string if not found.
func (Instance) GetAnimation ¶
Returns the graphics.gd/classdb/Animation with the key 'name'. If the animation does not exist, null is returned and an error is logged.
func (Instance) GetAnimationLibrary ¶
func (self Instance) GetAnimationLibrary(name string) AnimationLibrary.Instance
Returns the first graphics.gd/classdb/AnimationLibrary with key 'name' or null if not found.
To get the graphics.gd/classdb/AnimationMixer's global animation library, use get_animation_library("").
func (Instance) GetAnimationLibraryList ¶
Returns the list of stored library keys.
func (Instance) GetAnimationList ¶
Returns the list of stored animation keys.
func (Instance) GetRootMotionPosition ¶
Retrieve the motion delta of position with the Instance.RootMotionTrack as a [Vector3.XYZ] that can be used elsewhere.
If Instance.RootMotionTrack is not a path to a track of type [Animation.TypePosition3d], returns Vector3(0, 0, 0).
See also Instance.RootMotionTrack and graphics.gd/classdb/RootMotionView.
The most basic example is applying position to graphics.gd/classdb/CharacterBody3D:
if Input.IsActionJustPressed("animate", false) { current_rotation = characterBody3D.AsNode3D().Quaternion() animationNodeStateMachinePlayback.Travel("Animate") } var velocity = Vector3.DivX(Quaternion.Rotate(animationTree.AsAnimationMixer().GetRootMotionPosition(), current_rotation), delta) characterBody3D.SetVelocity(velocity) characterBody3D.MoveAndSlide()
By using this in combination with Instance.GetRootMotionRotationAccumulator, you can apply the root motion position more correctly to account for the rotation of the node.
If Instance.RootMotionLocal is true, returns the pre-multiplied translation value with the inverted rotation.
In this case, the code can be written as follows:
func (Instance) GetRootMotionPositionAccumulator ¶
Retrieve the blended value of the position tracks with the Instance.RootMotionTrack as a [Vector3.XYZ] that can be used elsewhere.
This is useful in cases where you want to respect the initial key values of the animation.
For example, if an animation with only one key Vector3(0, 0, 0) is played in the previous frame and then an animation with only one key Vector3(1, 0, 1) is played in the next frame, the difference can be calculated as follows:
var prev_root_motion_position_accumulator Vector3.XYZ if Input.IsActionJustPressed("animate", false) { animationNodeStateMachinePlayback.Travel("Animate") } var current_root_motion_position_accumulator = animationTree.AsAnimationMixer().GetRootMotionPositionAccumulator() var difference = Vector3.Sub(current_root_motion_position_accumulator, prev_root_motion_position_accumulator) prev_root_motion_position_accumulator = current_root_motion_position_accumulator transform := characterBody3D.AsNode3D().Transform() transform.Origin = Vector3.Add(transform.Origin, difference) characterBody3D.AsNode3D().SetTransform(transform)
However, if the animation loops, an unintended discrete change may occur, so this is only useful for some simple use cases.
func (Instance) GetRootMotionRotation ¶
func (self Instance) GetRootMotionRotation() Quaternion.IJKX
Retrieve the motion delta of rotation with the Instance.RootMotionTrack as a [Quaternion.IJKX] that can be used elsewhere.
If Instance.RootMotionTrack is not a path to a track of type [Animation.TypeRotation3d], returns Quaternion(0, 0, 0, 1).
See also Instance.RootMotionTrack and graphics.gd/classdb/RootMotionView.
The most basic example is applying rotation to graphics.gd/classdb/CharacterBody3D:
if Input.IsActionJustPressed("animate", false) { animationNodeStateMachinePlayback.Travel("Animate") } characterBody3D.AsNode3D().SetQuaternion(Quaternion.Mul(characterBody3D.AsNode3D().Quaternion(), animationTree.AsAnimationMixer().GetRootMotionRotation()))
func (Instance) GetRootMotionRotationAccumulator ¶
func (self Instance) GetRootMotionRotationAccumulator() Quaternion.IJKX
Retrieve the blended value of the rotation tracks with the Instance.RootMotionTrack as a [Quaternion.IJKX] that can be used elsewhere.
This is necessary to apply the root motion position correctly, taking rotation into account. See also Instance.GetRootMotionPosition.
Also, this is useful in cases where you want to respect the initial key values of the animation.
For example, if an animation with only one key Quaternion(0, 0, 0, 1) is played in the previous frame and then an animation with only one key Quaternion(0, 0.707, 0, 0.707) is played in the next frame, the difference can be calculated as follows:
var prev_root_motion_rotation_accumulator Quaternion.IJKX if Input.IsActionJustPressed("animate", false) { animationNodeStateMachinePlayback.Travel("Animate") } var current_root_motion_rotation_accumulator = animationTree.AsAnimationMixer().GetRootMotionRotationAccumulator() var difference = Quaternion.Mul(Quaternion.Inverse(prev_root_motion_rotation_accumulator), current_root_motion_rotation_accumulator) prev_root_motion_rotation_accumulator = current_root_motion_rotation_accumulator transform := characterBody3D.AsNode3D().Transform() transform.Basis = Basis.Mul(transform.Basis, Quaternion.AsBasis(difference)) characterBody3D.AsNode3D().SetTransform(transform)
However, if the animation loops, an unintended discrete change may occur, so this is only useful for some simple use cases.
func (Instance) GetRootMotionScale ¶
Retrieve the motion delta of scale with the Instance.RootMotionTrack as a [Vector3.XYZ] that can be used elsewhere.
If Instance.RootMotionTrack is not a path to a track of type [Animation.TypeScale3d], returns Vector3(0, 0, 0).
See also Instance.RootMotionTrack and graphics.gd/classdb/RootMotionView.
The most basic example is applying scale to graphics.gd/classdb/CharacterBody3D:
var current_scale = Vector3.New(1, 1, 1) var scale_accum = Vector3.New(1, 1, 1) if Input.IsActionJustPressed("animate", false) { current_scale = characterBody3D.AsNode3D().Scale() scale_accum = Vector3.New(1, 1, 1) animationNodeStateMachinePlayback.Travel("Animate") } scale_accum = Vector3.Add(scale_accum, animationTree.AsAnimationMixer().GetRootMotionScale()) characterBody3D.AsNode3D().SetScale(Vector3.Mul(current_scale, scale_accum))
func (Instance) GetRootMotionScaleAccumulator ¶
Retrieve the blended value of the scale tracks with the Instance.RootMotionTrack as a [Vector3.XYZ] that can be used elsewhere.
For example, if an animation with only one key Vector3(1, 1, 1) is played in the previous frame and then an animation with only one key Vector3(2, 2, 2) is played in the next frame, the difference can be calculated as follows:
var prev_root_motion_scale_accumulator Vector3.XYZ if Input.IsActionJustPressed("animate", false) { animationNodeStateMachinePlayback.Travel("Animate") } var current_root_motion_scale_accumulator = animationTree.AsAnimationMixer().GetRootMotionScaleAccumulator() var difference = Vector3.Sub(current_root_motion_scale_accumulator, prev_root_motion_scale_accumulator) prev_root_motion_scale_accumulator = current_root_motion_scale_accumulator transform := characterBody3D.AsNode3D().Transform() transform.Basis = Basis.Scaled(transform.Basis, difference) characterBody3D.AsNode3D().SetTransform(transform)
However, if the animation loops, an unintended discrete change may occur, so this is only useful for some simple use cases.
func (Instance) HasAnimation ¶
Returns true if the graphics.gd/classdb/AnimationMixer stores an graphics.gd/classdb/Animation with key 'name'.
func (Instance) HasAnimationLibrary ¶
Returns true if the graphics.gd/classdb/AnimationMixer stores an graphics.gd/classdb/AnimationLibrary with key 'name'.
func (Instance) OnAnimationFinished ¶
func (Instance) OnAnimationLibrariesUpdated ¶
func (Instance) OnAnimationListChanged ¶
func (Instance) OnAnimationStarted ¶
func (Instance) OnCachesCleared ¶
func (Instance) OnMixerApplied ¶
func (Instance) OnMixerUpdated ¶
func (Instance) RemoveAnimationLibrary ¶
Removes the graphics.gd/classdb/AnimationLibrary associated with the key 'name'.
func (Instance) RenameAnimationLibrary ¶
Moves the graphics.gd/classdb/AnimationLibrary associated with the key 'name' to the key 'newname'.
func (Instance) ResetOnSave ¶
func (Instance) RootMotionLocal ¶
func (Instance) RootMotionTrack ¶
func (Instance) SetAudioMaxPolyphony ¶
func (Instance) SetCallbackModeDiscrete ¶
func (self Instance) SetCallbackModeDiscrete(value AnimationCallbackModeDiscrete)
func (Instance) SetCallbackModeMethod ¶
func (self Instance) SetCallbackModeMethod(value AnimationCallbackModeMethod)
func (Instance) SetCallbackModeProcess ¶
func (self Instance) SetCallbackModeProcess(value AnimationCallbackModeProcess)