AnimationMixer

package
v0.0.0-...-f3deeb4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package AnimationMixer provides methods for working with AnimationMixer object instances.

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 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 Any

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

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 New

func New() Instance

func (Instance) Active

func (self Instance) Active() bool

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) Advance

func (self Instance) Advance(delta Float.X)

Manually advance the animations by the specified time (in seconds).

func (Instance) AsAnimationMixer

func (self Instance) AsAnimationMixer() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

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

func (Instance) AudioMaxPolyphony

func (self Instance) AudioMaxPolyphony() int

func (Instance) CallbackModeDiscrete

func (self Instance) CallbackModeDiscrete() gdclass.AnimationMixerAnimationCallbackModeDiscrete

func (Instance) CallbackModeMethod

func (Instance) CallbackModeProcess

func (self Instance) CallbackModeProcess() gdclass.AnimationMixerAnimationCallbackModeProcess

func (Instance) Capture

func (self Instance) Capture(name string, duration Float.X)

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 (self Instance) Deterministic() bool

func (Instance) FindAnimation

func (self Instance) FindAnimation(animation [1]gdclass.Animation) string

Returns the key of [param animation] or an empty [StringName] if not found.

func (Instance) FindAnimationLibrary

func (self Instance) FindAnimationLibrary(animation [1]gdclass.Animation) string

Returns the key for the [AnimationLibrary] that contains [param animation] or an empty [StringName] if not found.

func (Instance) GetAnimation

func (self Instance) GetAnimation(name string) [1]gdclass.Animation

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

func (self Instance) GetAnimationLibraryList() []string

Returns the list of stored library keys.

func (Instance) GetAnimationList

func (self Instance) GetAnimationList() []string

Returns the list of stored animation keys.

func (Instance) GetRootMotionPosition

func (self Instance) GetRootMotionPosition() Vector3.XYZ

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

func (self Instance) GetRootMotionPositionAccumulator() Vector3.XYZ

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

func (self Instance) GetRootMotionScale() Vector3.XYZ

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

func (self Instance) GetRootMotionScaleAccumulator() Vector3.XYZ

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

func (self Instance) HasAnimation(name string) bool

Returns [code]true[/code] if the [AnimationMixer] stores an [Animation] with key [param name].

func (Instance) HasAnimationLibrary

func (self Instance) HasAnimationLibrary(name string) bool

Returns [code]true[/code] if the [AnimationMixer] stores an [AnimationLibrary] with key [param name].

func (Instance) OnAnimationFinished

func (self Instance) OnAnimationFinished(cb func(anim_name string))

func (Instance) OnAnimationLibrariesUpdated

func (self Instance) OnAnimationLibrariesUpdated(cb func())

func (Instance) OnAnimationListChanged

func (self Instance) OnAnimationListChanged(cb func())

func (Instance) OnAnimationStarted

func (self Instance) OnAnimationStarted(cb func(anim_name string))

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

func (self Instance) RemoveAnimationLibrary(name string)

Removes the [AnimationLibrary] associated with the key [param name].

func (Instance) RenameAnimationLibrary

func (self Instance) RenameAnimationLibrary(name string, newname string)

Moves the [AnimationLibrary] associated with the key [param name] to the key [param newname].

func (Instance) ResetOnSave

func (self Instance) ResetOnSave() bool

func (Instance) RootMotionTrack

func (self Instance) RootMotionTrack() string

func (Instance) RootNode

func (self Instance) RootNode() string

func (Instance) SetActive

func (self Instance) SetActive(value bool)

func (Instance) SetAudioMaxPolyphony

func (self Instance) SetAudioMaxPolyphony(value int)

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)

func (Instance) SetDeterministic

func (self Instance) SetDeterministic(value bool)

func (Instance) SetResetOnSave

func (self Instance) SetResetOnSave(value bool)

func (Instance) SetRootMotionTrack

func (self Instance) SetRootMotionTrack(value string)

func (Instance) SetRootNode

func (self Instance) SetRootNode(value string)

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

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

type Interface

type Interface interface {
	//A virtual function for processing after getting a key during playback.
	PostProcessKeyValue(animation [1]gdclass.Animation, track int, value any, object_id int, object_sub_idx int) any
}

Jump to

Keyboard shortcuts

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