Documentation
¶
Overview ¶
Package AnimationMixer provides methods for working with AnimationMixer object instances.
Index ¶
- type Advanced
- type AnimationCallbackModeDiscrete
- type AnimationCallbackModeMethod
- type AnimationCallbackModeProcess
- type Any
- type Implementation
- type Instance
- func (self Instance) Active() bool
- func (self Instance) AddAnimationLibrary(name string, library [1]gdclass.AnimationLibrary) 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() gdclass.AnimationMixerAnimationCallbackModeDiscrete
- func (self Instance) CallbackModeMethod() gdclass.AnimationMixerAnimationCallbackModeMethod
- func (self Instance) CallbackModeProcess() gdclass.AnimationMixerAnimationCallbackModeProcess
- func (self Instance) Capture(name string, duration Float.X)
- func (self Instance) ClearCaches()
- func (self Instance) Deterministic() bool
- func (self Instance) FindAnimation(animation [1]gdclass.Animation) string
- func (self Instance) FindAnimationLibrary(animation [1]gdclass.Animation) string
- func (self Instance) GetAnimation(name string) [1]gdclass.Animation
- func (self Instance) GetAnimationLibrary(name string) [1]gdclass.AnimationLibrary
- 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) OnAnimationFinished(cb func(anim_name string))
- func (self Instance) OnAnimationLibrariesUpdated(cb func())
- func (self Instance) OnAnimationListChanged(cb func())
- func (self Instance) OnAnimationStarted(cb func(anim_name string))
- func (self Instance) OnCachesCleared(cb func())
- func (self Instance) OnMixerApplied(cb func())
- func (self Instance) OnMixerUpdated(cb func())
- func (self Instance) RemoveAnimationLibrary(name string)
- func (self Instance) RenameAnimationLibrary(name string, newname string)
- func (self Instance) ResetOnSave() 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 gdclass.AnimationMixerAnimationCallbackModeDiscrete)
- func (self Instance) SetCallbackModeMethod(value gdclass.AnimationMixerAnimationCallbackModeMethod)
- func (self Instance) SetCallbackModeProcess(value gdclass.AnimationMixerAnimationCallbackModeProcess)
- func (self Instance) SetDeterministic(value bool)
- func (self Instance) SetResetOnSave(value bool)
- func (self Instance) SetRootMotionTrack(value string)
- func (self Instance) SetRootNode(value string)
- func (self *Instance) UnsafePointer() unsafe.Pointer
- 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 = gdclass.AnimationMixerAnimationCallbackModeDiscrete //gd:AnimationMixer.AnimationCallbackModeDiscrete
const ( /*An [constant Animation.UPDATE_DISCRETE] track value takes precedence when blending [constant Animation.UPDATE_CONTINUOUS] or [constant Animation.UPDATE_CAPTURE] track values and [constant Animation.UPDATE_DISCRETE] track values.*/ AnimationCallbackModeDiscreteDominant AnimationCallbackModeDiscrete = 0 /*An [constant Animation.UPDATE_CONTINUOUS] or [constant Animation.UPDATE_CAPTURE] track value takes precedence when blending the [constant Animation.UPDATE_CONTINUOUS] or [constant Animation.UPDATE_CAPTURE] track values and the [constant Animation.UPDATE_DISCRETE] track values. This is the default behavior for [AnimationPlayer].*/ AnimationCallbackModeDiscreteRecessive AnimationCallbackModeDiscrete = 1 /*Always treat the [constant Animation.UPDATE_DISCRETE] track value as [constant Animation.UPDATE_CONTINUOUS] with [constant Animation.INTERPOLATION_NEAREST]. This is the default behavior for [AnimationTree]. If a value track has non-numeric type key values, it is internally converted to use [constant ANIMATION_CALLBACK_MODE_DISCRETE_RECESSIVE] with [constant Animation.UPDATE_DISCRETE].*/ AnimationCallbackModeDiscreteForceContinuous AnimationCallbackModeDiscrete = 2 )
type AnimationCallbackModeMethod ¶
type AnimationCallbackModeMethod = gdclass.AnimationMixerAnimationCallbackModeMethod //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 = gdclass.AnimationMixerAnimationCallbackModeProcess //gd:AnimationMixer.AnimationCallbackModeProcess
const ( /*Process animation during physics frames (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]). This is especially useful when animating physics bodies.*/ AnimationCallbackModeProcessPhysics AnimationCallbackModeProcess = 0 /*Process animation during process frames (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).*/ AnimationCallbackModeProcessIdle AnimationCallbackModeProcess = 1 /*Do not process animation. Use [method advance] to process the animation manually.*/ AnimationCallbackModeProcessManual AnimationCallbackModeProcess = 2 )
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
type Instance [1]gdclass.AnimationMixer
Base class for [AnimationPlayer] and [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 [AnimationMixer].
See [Interface] for methods that can be overridden by a [Class] that extends it.
%!(EXTRA string=AnimationMixer)
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 [1]gdclass.AnimationLibrary) error
Adds [param library] to the animation player, under the key [param name]. AnimationMixer has a global library by default with an empty string as key. For adding an animation to the global library: [codeblocks] [gdscript] var global_library = mixer.get_animation_library("") global_library.add_animation("animation_name", animation_resource) [/gdscript] [/codeblocks]
func (Instance) AsAnimationMixer ¶
func (Instance) AudioMaxPolyphony ¶
func (Instance) CallbackModeDiscrete ¶
func (self Instance) CallbackModeDiscrete() gdclass.AnimationMixerAnimationCallbackModeDiscrete
func (Instance) CallbackModeMethod ¶
func (self Instance) CallbackModeMethod() gdclass.AnimationMixerAnimationCallbackModeMethod
func (Instance) CallbackModeProcess ¶
func (self Instance) CallbackModeProcess() gdclass.AnimationMixerAnimationCallbackModeProcess
func (Instance) Capture ¶
If the animation track specified by [param name] has an option [constant Animation.UPDATE_CAPTURE], 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 [param duration], working like a crossfade. You can specify [param trans_type] as the curve for the interpolation. For better results, it may be appropriate to specify [constant Tween.TRANS_LINEAR] for cases where the first key of the track begins with a non-zero value or where the key value does not change, and [constant Tween.TRANS_QUAD] for cases where the key value changes linearly.
func (Instance) ClearCaches ¶
func (self Instance) ClearCaches()
[AnimationMixer] caches animated nodes. It may not notice if a node disappears; [method clear_caches] forces it to update the cache again.
func (Instance) Deterministic ¶
func (Instance) FindAnimation ¶
Returns the key of [param animation] or an empty [StringName] if not found.
func (Instance) FindAnimationLibrary ¶
Returns the key for the [AnimationLibrary] that contains [param animation] or an empty [StringName] if not found.
func (Instance) GetAnimation ¶
Returns the [Animation] with the key [param name]. If the animation does not exist, [code]null[/code] is returned and an error is logged.
func (Instance) GetAnimationLibrary ¶
func (self Instance) GetAnimationLibrary(name string) [1]gdclass.AnimationLibrary
Returns the first [AnimationLibrary] with key [param name] or [code]null[/code] if not found. To get the [AnimationMixer]'s global animation library, use [code]get_animation_library("")[/code].
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 [member root_motion_track] as a [Vector3] that can be used elsewhere. If [member root_motion_track] is not a path to a track of type [constant Animation.TYPE_POSITION_3D], returns [code]Vector3(0, 0, 0)[/code]. See also [member root_motion_track] and [RootMotionView]. The most basic example is applying position to [CharacterBody3D]: [codeblocks] [gdscript] var current_rotation: Quaternion
func _process(delta):
if Input.is_action_just_pressed("animate"): current_rotation = get_quaternion() state_machine.travel("Animate") var velocity: Vector3 = current_rotation * animation_tree.get_root_motion_position() / delta set_velocity(velocity) move_and_slide()
[/gdscript] [/codeblocks] By using this in combination with [method get_root_motion_rotation_accumulator], you can apply the root motion position more correctly to account for the rotation of the node. [codeblocks] [gdscript] func _process(delta):
if Input.is_action_just_pressed("animate"): state_machine.travel("Animate") set_quaternion(get_quaternion() * animation_tree.get_root_motion_rotation()) var velocity: Vector3 = (animation_tree.get_root_motion_rotation_accumulator().inverse() * get_quaternion()) * animation_tree.get_root_motion_position() / delta set_velocity(velocity) move_and_slide()
[/gdscript] [/codeblocks]
func (Instance) GetRootMotionPositionAccumulator ¶
Retrieve the blended value of the position tracks with the [member root_motion_track] as a [Vector3] 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 [code]Vector3(0, 0, 0)[/code] is played in the previous frame and then an animation with only one key [code]Vector3(1, 0, 1)[/code] is played in the next frame, the difference can be calculated as follows: [codeblocks] [gdscript] var prev_root_motion_position_accumulator: Vector3
func _process(delta):
if Input.is_action_just_pressed("animate"): state_machine.travel("Animate") var current_root_motion_position_accumulator: Vector3 = animation_tree.get_root_motion_position_accumulator() var difference: Vector3 = current_root_motion_position_accumulator - prev_root_motion_position_accumulator prev_root_motion_position_accumulator = current_root_motion_position_accumulator transform.origin += difference
[/gdscript] [/codeblocks] 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 [member root_motion_track] as a [Quaternion] that can be used elsewhere. If [member root_motion_track] is not a path to a track of type [constant Animation.TYPE_ROTATION_3D], returns [code]Quaternion(0, 0, 0, 1)[/code]. See also [member root_motion_track] and [RootMotionView]. The most basic example is applying rotation to [CharacterBody3D]: [codeblocks] [gdscript] func _process(delta):
if Input.is_action_just_pressed("animate"): state_machine.travel("Animate") set_quaternion(get_quaternion() * animation_tree.get_root_motion_rotation())
[/gdscript] [/codeblocks]
func (Instance) GetRootMotionRotationAccumulator ¶
func (self Instance) GetRootMotionRotationAccumulator() Quaternion.IJKX
Retrieve the blended value of the rotation tracks with the [member root_motion_track] as a [Quaternion] that can be used elsewhere. This is necessary to apply the root motion position correctly, taking rotation into account. See also [method get_root_motion_position]. 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 [code]Quaternion(0, 0, 0, 1)[/code] is played in the previous frame and then an animation with only one key [code]Quaternion(0, 0.707, 0, 0.707)[/code] is played in the next frame, the difference can be calculated as follows: [codeblocks] [gdscript] var prev_root_motion_rotation_accumulator: Quaternion
func _process(delta):
if Input.is_action_just_pressed("animate"): state_machine.travel("Animate") var current_root_motion_rotation_accumulator: Quaternion = animation_tree.get_root_motion_rotation_accumulator() var difference: Quaternion = prev_root_motion_rotation_accumulator.inverse() * current_root_motion_rotation_accumulator prev_root_motion_rotation_accumulator = current_root_motion_rotation_accumulator transform.basis *= Basis(difference)
[/gdscript] [/codeblocks] 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 [member root_motion_track] as a [Vector3] that can be used elsewhere. If [member root_motion_track] is not a path to a track of type [constant Animation.TYPE_SCALE_3D], returns [code]Vector3(0, 0, 0)[/code]. See also [member root_motion_track] and [RootMotionView]. The most basic example is applying scale to [CharacterBody3D]: [codeblocks] [gdscript] var current_scale: Vector3 = Vector3(1, 1, 1) var scale_accum: Vector3 = Vector3(1, 1, 1)
func _process(delta):
if Input.is_action_just_pressed("animate"): current_scale = get_scale() scale_accum = Vector3(1, 1, 1) state_machine.travel("Animate") scale_accum += animation_tree.get_root_motion_scale() set_scale(current_scale * scale_accum)
[/gdscript] [/codeblocks]
func (Instance) GetRootMotionScaleAccumulator ¶
Retrieve the blended value of the scale tracks with the [member root_motion_track] as a [Vector3] that can be used elsewhere. For example, if an animation with only one key [code]Vector3(1, 1, 1)[/code] is played in the previous frame and then an animation with only one key [code]Vector3(2, 2, 2)[/code] is played in the next frame, the difference can be calculated as follows: [codeblocks] [gdscript] var prev_root_motion_scale_accumulator: Vector3
func _process(delta):
if Input.is_action_just_pressed("animate"): state_machine.travel("Animate") var current_root_motion_scale_accumulator: Vector3 = animation_tree.get_root_motion_scale_accumulator() var difference: Vector3 = current_root_motion_scale_accumulator - prev_root_motion_scale_accumulator prev_root_motion_scale_accumulator = current_root_motion_scale_accumulator transform.basis = transform.basis.scaled(difference)
[/gdscript] [/codeblocks] 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 [code]true[/code] if the [AnimationMixer] stores an [Animation] with key [param name].
func (Instance) HasAnimationLibrary ¶
Returns [code]true[/code] if the [AnimationMixer] stores an [AnimationLibrary] with key [param name].
func (Instance) OnAnimationFinished ¶
func (Instance) OnAnimationLibrariesUpdated ¶
func (self Instance) OnAnimationLibrariesUpdated(cb func())
func (Instance) OnAnimationListChanged ¶
func (self Instance) OnAnimationListChanged(cb func())
func (Instance) OnAnimationStarted ¶
func (Instance) OnCachesCleared ¶
func (self Instance) OnCachesCleared(cb func())
func (Instance) OnMixerApplied ¶
func (self Instance) OnMixerApplied(cb func())
func (Instance) OnMixerUpdated ¶
func (self Instance) OnMixerUpdated(cb func())
func (Instance) RemoveAnimationLibrary ¶
Removes the [AnimationLibrary] associated with the key [param name].
func (Instance) RenameAnimationLibrary ¶
Moves the [AnimationLibrary] associated with the key [param name] to the key [param newname].
func (Instance) ResetOnSave ¶
func (Instance) RootMotionTrack ¶
func (Instance) SetAudioMaxPolyphony ¶
func (Instance) SetCallbackModeDiscrete ¶
func (self Instance) SetCallbackModeDiscrete(value gdclass.AnimationMixerAnimationCallbackModeDiscrete)
func (Instance) SetCallbackModeMethod ¶
func (self Instance) SetCallbackModeMethod(value gdclass.AnimationMixerAnimationCallbackModeMethod)
func (Instance) SetCallbackModeProcess ¶
func (self Instance) SetCallbackModeProcess(value gdclass.AnimationMixerAnimationCallbackModeProcess)