Animation

package
v0.0.0-...-ae8aae0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package Animation provides methods for working with Animation 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 Any

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

type FindMode

type FindMode = gdclass.AnimationFindMode //gd:Animation.FindMode
const (
	/*Finds the nearest time key.*/
	FindModeNearest FindMode = 0
	/*Finds only the key with approximating the time.*/
	FindModeApprox FindMode = 1
	/*Finds only the key with matching the time.*/
	FindModeExact FindMode = 2
)

type Instance

type Instance [1]gdclass.Animation

This resource holds data that can be used to animate anything in the engine. Animations are divided into tracks and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track. [codeblocks] [gdscript] # This creates an animation that makes the node "Enemy" move to the right by # 100 pixels in 2.0 seconds. var animation = Animation.new() var track_index = animation.add_track(Animation.TYPE_VALUE) animation.track_set_path(track_index, "Enemy:position:x") animation.track_insert_key(track_index, 0.0, 0) animation.track_insert_key(track_index, 2.0, 100) animation.length = 2.0 [/gdscript] [csharp] // This creates an animation that makes the node "Enemy" move to the right by // 100 pixels in 2.0 seconds. var animation = new Animation(); int trackIndex = animation.AddTrack(Animation.TrackType.Value); animation.TrackSetPath(trackIndex, "Enemy:position:x"); animation.TrackInsertKey(trackIndex, 0.0f, 0); animation.TrackInsertKey(trackIndex, 2.0f, 100); animation.Length = 2.0f; [/csharp] [/codeblocks] Animations are just data containers, and must be added to nodes such as an [AnimationPlayer] to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check [enum TrackType] to see available types. [b]Note:[/b] For 3D position/rotation/scale, using the dedicated [constant TYPE_POSITION_3D], [constant TYPE_ROTATION_3D] and [constant TYPE_SCALE_3D] track types instead of [constant TYPE_VALUE] is recommended for performance reasons.

var Nil Instance

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

func New

func New() Instance

func (Instance) AddTrack

func (self Instance) AddTrack(atype gdclass.AnimationTrackType) int

Adds a track to the Animation.

func (Instance) AnimationTrackGetKeyAnimation

func (self Instance) AnimationTrackGetKeyAnimation(track_idx int, key_idx int) string

Returns the animation name at the key identified by [param key_idx]. The [param track_idx] must be the index of an Animation Track.

func (Instance) AnimationTrackInsertKey

func (self Instance) AnimationTrackInsertKey(track_idx int, time Float.X, animation string) int

Inserts a key with value [param animation] at the given [param time] (in seconds). The [param track_idx] must be the index of an Animation Track.

func (Instance) AnimationTrackSetKeyAnimation

func (self Instance) AnimationTrackSetKeyAnimation(track_idx int, key_idx int, animation string)

Sets the key identified by [param key_idx] to value [param animation]. The [param track_idx] must be the index of an Animation Track.

func (Instance) AsAnimation

func (self Instance) AsAnimation() Instance

func (Instance) AsObject

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

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AudioTrackGetKeyEndOffset

func (self Instance) AudioTrackGetKeyEndOffset(track_idx int, key_idx int) Float.X

Returns the end offset of the key identified by [param key_idx]. The [param track_idx] must be the index of an Audio Track. End offset is the number of seconds cut off at the ending of the audio stream.

func (Instance) AudioTrackGetKeyStartOffset

func (self Instance) AudioTrackGetKeyStartOffset(track_idx int, key_idx int) Float.X

Returns the start offset of the key identified by [param key_idx]. The [param track_idx] must be the index of an Audio Track. Start offset is the number of seconds cut off at the beginning of the audio stream.

func (Instance) AudioTrackGetKeyStream

func (self Instance) AudioTrackGetKeyStream(track_idx int, key_idx int) [1]gdclass.Resource

Returns the audio stream of the key identified by [param key_idx]. The [param track_idx] must be the index of an Audio Track.

func (Instance) AudioTrackInsertKey

func (self Instance) AudioTrackInsertKey(track_idx int, time Float.X, stream [1]gdclass.Resource) int

Inserts an Audio Track key at the given [param time] in seconds. The [param track_idx] must be the index of an Audio Track. [param stream] is the [AudioStream] resource to play. [param start_offset] is the number of seconds cut off at the beginning of the audio stream, while [param end_offset] is at the ending.

func (Instance) AudioTrackIsUseBlend

func (self Instance) AudioTrackIsUseBlend(track_idx int) bool

Returns [code]true[/code] if the track at [param track_idx] will be blended with other animations.

func (Instance) AudioTrackSetKeyEndOffset

func (self Instance) AudioTrackSetKeyEndOffset(track_idx int, key_idx int, offset Float.X)

Sets the end offset of the key identified by [param key_idx] to value [param offset]. The [param track_idx] must be the index of an Audio Track.

func (Instance) AudioTrackSetKeyStartOffset

func (self Instance) AudioTrackSetKeyStartOffset(track_idx int, key_idx int, offset Float.X)

Sets the start offset of the key identified by [param key_idx] to value [param offset]. The [param track_idx] must be the index of an Audio Track.

func (Instance) AudioTrackSetKeyStream

func (self Instance) AudioTrackSetKeyStream(track_idx int, key_idx int, stream [1]gdclass.Resource)

Sets the stream of the key identified by [param key_idx] to value [param stream]. The [param track_idx] must be the index of an Audio Track.

func (Instance) AudioTrackSetUseBlend

func (self Instance) AudioTrackSetUseBlend(track_idx int, enable bool)

Sets whether the track will be blended with other animations. If [code]true[/code], the audio playback volume changes depending on the blend value.

func (Instance) BezierTrackGetKeyInHandle

func (self Instance) BezierTrackGetKeyInHandle(track_idx int, key_idx int) Vector2.XY

Returns the in handle of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track.

func (Instance) BezierTrackGetKeyOutHandle

func (self Instance) BezierTrackGetKeyOutHandle(track_idx int, key_idx int) Vector2.XY

Returns the out handle of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track.

func (Instance) BezierTrackGetKeyValue

func (self Instance) BezierTrackGetKeyValue(track_idx int, key_idx int) Float.X

Returns the value of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track.

func (Instance) BezierTrackInsertKey

func (self Instance) BezierTrackInsertKey(track_idx int, time Float.X, value Float.X) int

Inserts a Bezier Track key at the given [param time] in seconds. The [param track_idx] must be the index of a Bezier Track. [param in_handle] is the left-side weight of the added Bezier curve point, [param out_handle] is the right-side one, while [param value] is the actual value at this point.

func (Instance) BezierTrackInterpolate

func (self Instance) BezierTrackInterpolate(track_idx int, time Float.X) Float.X

Returns the interpolated value at the given [param time] (in seconds). The [param track_idx] must be the index of a Bezier Track.

func (Instance) BezierTrackSetKeyInHandle

func (self Instance) BezierTrackSetKeyInHandle(track_idx int, key_idx int, in_handle Vector2.XY)

Sets the in handle of the key identified by [param key_idx] to value [param in_handle]. The [param track_idx] must be the index of a Bezier Track.

func (Instance) BezierTrackSetKeyOutHandle

func (self Instance) BezierTrackSetKeyOutHandle(track_idx int, key_idx int, out_handle Vector2.XY)

Sets the out handle of the key identified by [param key_idx] to value [param out_handle]. The [param track_idx] must be the index of a Bezier Track.

func (Instance) BezierTrackSetKeyValue

func (self Instance) BezierTrackSetKeyValue(track_idx int, key_idx int, value Float.X)

Sets the value of the key identified by [param key_idx] to the given value. The [param track_idx] must be the index of a Bezier Track.

func (Instance) BlendShapeTrackInsertKey

func (self Instance) BlendShapeTrackInsertKey(track_idx int, time Float.X, amount Float.X) int

Inserts a key in a given blend shape track. Returns the key index.

func (Instance) BlendShapeTrackInterpolate

func (self Instance) BlendShapeTrackInterpolate(track_idx int, time_sec Float.X) Float.X

Returns the interpolated blend shape value at the given time (in seconds). The [param track_idx] must be the index of a blend shape track.

func (Instance) CaptureIncluded

func (self Instance) CaptureIncluded() bool

func (Instance) Clear

func (self Instance) Clear()

Clear the animation (clear all tracks and reset all).

func (Instance) Compress

func (self Instance) Compress()

Compress the animation and all its tracks in-place. This will make [method track_is_compressed] return [code]true[/code] once called on this [Animation]. Compressed tracks require less memory to be played, and are designed to be used for complex 3D animations (such as cutscenes) imported from external 3D software. Compression is lossy, but the difference is usually not noticeable in real world conditions. [b]Note:[/b] Compressed tracks have various limitations (such as not being editable from the editor), so only use compressed animations if you actually need them.

func (Instance) CopyTrack

func (self Instance) CopyTrack(track_idx int, to_animation [1]gdclass.Animation)

Adds a new track to [param to_animation] that is a copy of the given track from this animation.

func (Instance) FindTrack

func (self Instance) FindTrack(path string, atype gdclass.AnimationTrackType) int

Returns the index of the specified track. If the track is not found, return -1.

func (Instance) GetTrackCount

func (self Instance) GetTrackCount() int

Returns the amount of tracks in the animation.

func (Instance) Length

func (self Instance) Length() Float.X

func (Instance) LoopMode

func (self Instance) LoopMode() gdclass.AnimationLoopMode

func (Instance) MethodTrackGetName

func (self Instance) MethodTrackGetName(track_idx int, key_idx int) string

Returns the method name of a method track.

func (Instance) MethodTrackGetParams

func (self Instance) MethodTrackGetParams(track_idx int, key_idx int) []any

Returns the arguments values to be called on a method track for a given key in a given track.

func (Instance) PositionTrackInsertKey

func (self Instance) PositionTrackInsertKey(track_idx int, time Float.X, position Vector3.XYZ) int

Inserts a key in a given 3D position track. Returns the key index.

func (Instance) PositionTrackInterpolate

func (self Instance) PositionTrackInterpolate(track_idx int, time_sec Float.X) Vector3.XYZ

Returns the interpolated position value at the given time (in seconds). The [param track_idx] must be the index of a 3D position track.

func (Instance) RemoveTrack

func (self Instance) RemoveTrack(track_idx int)

Removes a track by specifying the track index.

func (Instance) RotationTrackInsertKey

func (self Instance) RotationTrackInsertKey(track_idx int, time Float.X, rotation Quaternion.IJKX) int

Inserts a key in a given 3D rotation track. Returns the key index.

func (Instance) RotationTrackInterpolate

func (self Instance) RotationTrackInterpolate(track_idx int, time_sec Float.X) Quaternion.IJKX

Returns the interpolated rotation value at the given time (in seconds). The [param track_idx] must be the index of a 3D rotation track.

func (Instance) ScaleTrackInsertKey

func (self Instance) ScaleTrackInsertKey(track_idx int, time Float.X, scale Vector3.XYZ) int

Inserts a key in a given 3D scale track. Returns the key index.

func (Instance) ScaleTrackInterpolate

func (self Instance) ScaleTrackInterpolate(track_idx int, time_sec Float.X) Vector3.XYZ

Returns the interpolated scale value at the given time (in seconds). The [param track_idx] must be the index of a 3D scale track.

func (Instance) SetLength

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

func (Instance) SetLoopMode

func (self Instance) SetLoopMode(value gdclass.AnimationLoopMode)

func (Instance) SetStep

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

func (Instance) Step

func (self Instance) Step() Float.X

func (Instance) TrackFindKey

func (self Instance) TrackFindKey(track_idx int, time Float.X) int

Finds the key index by time in a given track. Optionally, only find it if the approx/exact time is given. If [param limit] is [code]true[/code], it does not return keys outside the animation range. If [param backward] is [code]true[/code], the direction is reversed in methods that rely on one directional processing. For example, in case [param find_mode] is [constant FIND_MODE_NEAREST], if there is no key in the current position just after seeked, the first key found is retrieved by searching before the position, but if [param backward] is [code]true[/code], the first key found is retrieved after the position.

func (Instance) TrackGetInterpolationLoopWrap

func (self Instance) TrackGetInterpolationLoopWrap(track_idx int) bool

Returns [code]true[/code] if the track at [param track_idx] wraps the interpolation loop. New tracks wrap the interpolation loop by default.

func (Instance) TrackGetInterpolationType

func (self Instance) TrackGetInterpolationType(track_idx int) gdclass.AnimationInterpolationType

Returns the interpolation type of a given track.

func (Instance) TrackGetKeyCount

func (self Instance) TrackGetKeyCount(track_idx int) int

Returns the number of keys in a given track.

func (Instance) TrackGetKeyTime

func (self Instance) TrackGetKeyTime(track_idx int, key_idx int) Float.X

Returns the time at which the key is located.

func (Instance) TrackGetKeyTransition

func (self Instance) TrackGetKeyTransition(track_idx int, key_idx int) Float.X

Returns the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]).

func (Instance) TrackGetKeyValue

func (self Instance) TrackGetKeyValue(track_idx int, key_idx int) any

Returns the value of a given key in a given track.

func (Instance) TrackGetPath

func (self Instance) TrackGetPath(track_idx int) string

Gets the path of a track. For more information on the path format, see [method track_set_path].

func (Instance) TrackGetType

func (self Instance) TrackGetType(track_idx int) gdclass.AnimationTrackType

Gets the type of a track.

func (Instance) TrackInsertKey

func (self Instance) TrackInsertKey(track_idx int, time Float.X, key any) int

Inserts a generic key in a given track. Returns the key index.

func (Instance) TrackIsCompressed

func (self Instance) TrackIsCompressed(track_idx int) bool

Returns [code]true[/code] if the track is compressed, [code]false[/code] otherwise. See also [method compress].

func (Instance) TrackIsEnabled

func (self Instance) TrackIsEnabled(track_idx int) bool

Returns [code]true[/code] if the track at index [param track_idx] is enabled.

func (Instance) TrackIsImported

func (self Instance) TrackIsImported(track_idx int) bool

Returns [code]true[/code] if the given track is imported. Else, return [code]false[/code].

func (Instance) TrackMoveDown

func (self Instance) TrackMoveDown(track_idx int)

Moves a track down.

func (Instance) TrackMoveTo

func (self Instance) TrackMoveTo(track_idx int, to_idx int)

Changes the index position of track [param track_idx] to the one defined in [param to_idx].

func (Instance) TrackMoveUp

func (self Instance) TrackMoveUp(track_idx int)

Moves a track up.

func (Instance) TrackRemoveKey

func (self Instance) TrackRemoveKey(track_idx int, key_idx int)

Removes a key by index in a given track.

func (Instance) TrackRemoveKeyAtTime

func (self Instance) TrackRemoveKeyAtTime(track_idx int, time Float.X)

Removes a key at [param time] in a given track.

func (Instance) TrackSetEnabled

func (self Instance) TrackSetEnabled(track_idx int, enabled bool)

Enables/disables the given track. Tracks are enabled by default.

func (Instance) TrackSetImported

func (self Instance) TrackSetImported(track_idx int, imported bool)

Sets the given track as imported or not.

func (Instance) TrackSetInterpolationLoopWrap

func (self Instance) TrackSetInterpolationLoopWrap(track_idx int, interpolation bool)

If [code]true[/code], the track at [param track_idx] wraps the interpolation loop.

func (Instance) TrackSetInterpolationType

func (self Instance) TrackSetInterpolationType(track_idx int, interpolation gdclass.AnimationInterpolationType)

Sets the interpolation type of a given track.

func (Instance) TrackSetKeyTime

func (self Instance) TrackSetKeyTime(track_idx int, key_idx int, time Float.X)

Sets the time of an existing key.

func (Instance) TrackSetKeyTransition

func (self Instance) TrackSetKeyTransition(track_idx int, key_idx int, transition Float.X)

Sets the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]).

func (Instance) TrackSetKeyValue

func (self Instance) TrackSetKeyValue(track_idx int, key int, value any)

Sets the value of an existing key.

func (Instance) TrackSetPath

func (self Instance) TrackSetPath(track_idx int, path string)

Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the [member AnimationMixer.root_node] that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by [code]":"[/code]. For example, [code]"character/skeleton:ankle"[/code] or [code]"character/mesh:transform/local"[/code].

func (Instance) TrackSwap

func (self Instance) TrackSwap(track_idx int, with_idx int)

Swaps the track [param track_idx]'s index position with the track [param with_idx].

func (*Instance) UnsafePointer

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

func (Instance) ValueTrackGetUpdateMode

func (self Instance) ValueTrackGetUpdateMode(track_idx int) gdclass.AnimationUpdateMode

Returns the update mode of a value track.

func (Instance) ValueTrackInterpolate

func (self Instance) ValueTrackInterpolate(track_idx int, time_sec Float.X) any

Returns the interpolated value at the given time (in seconds). The [param track_idx] must be the index of a value track. A [param backward] mainly affects the direction of key retrieval of the track with [constant UPDATE_DISCRETE] converted by [constant AnimationMixer.ANIMATION_CALLBACK_MODE_DISCRETE_FORCE_CONTINUOUS] to match the result with [method track_find_key].

func (Instance) ValueTrackSetUpdateMode

func (self Instance) ValueTrackSetUpdateMode(track_idx int, mode gdclass.AnimationUpdateMode)

Sets the update mode (see [enum UpdateMode]) of a value track.

func (Instance) Virtual

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

type InterpolationType

type InterpolationType = gdclass.AnimationInterpolationType //gd:Animation.InterpolationType
const (
	/*No interpolation (nearest value).*/
	InterpolationNearest InterpolationType = 0
	/*Linear interpolation.*/
	InterpolationLinear InterpolationType = 1
	/*Cubic interpolation. This looks smoother than linear interpolation, but is more expensive to interpolate. Stick to [constant INTERPOLATION_LINEAR] for complex 3D animations imported from external software, even if it requires using a higher animation framerate in return.*/
	InterpolationCubic InterpolationType = 2
	/*Linear interpolation with shortest path rotation.
	  [b]Note:[/b] The result value is always normalized and may not match the key value.*/
	InterpolationLinearAngle InterpolationType = 3
	/*Cubic interpolation with shortest path rotation.
	  [b]Note:[/b] The result value is always normalized and may not match the key value.*/
	InterpolationCubicAngle InterpolationType = 4
)

type LoopMode

type LoopMode = gdclass.AnimationLoopMode //gd:Animation.LoopMode
const (
	/*At both ends of the animation, the animation will stop playing.*/
	LoopNone LoopMode = 0
	/*At both ends of the animation, the animation will be repeated without changing the playback direction.*/
	LoopLinear LoopMode = 1
	/*Repeats playback and reverse playback at both ends of the animation.*/
	LoopPingpong LoopMode = 2
)

type LoopedFlag

type LoopedFlag = gdclass.AnimationLoopedFlag //gd:Animation.LoopedFlag
const (
	/*This flag indicates that the animation proceeds without any looping.*/
	LoopedFlagNone LoopedFlag = 0
	/*This flag indicates that the animation has reached the end of the animation and just after loop processed.*/
	LoopedFlagEnd LoopedFlag = 1
	/*This flag indicates that the animation has reached the start of the animation and just after loop processed.*/
	LoopedFlagStart LoopedFlag = 2
)

type TrackType

type TrackType = gdclass.AnimationTrackType //gd:Animation.TrackType
const (
	/*Value tracks set values in node properties, but only those which can be interpolated. For 3D position/rotation/scale, using the dedicated [constant TYPE_POSITION_3D], [constant TYPE_ROTATION_3D] and [constant TYPE_SCALE_3D] track types instead of [constant TYPE_VALUE] is recommended for performance reasons.*/
	TypeValue TrackType = 0
	/*3D position track (values are stored in [Vector3]s).*/
	TypePosition3d TrackType = 1
	/*3D rotation track (values are stored in [Quaternion]s).*/
	TypeRotation3d TrackType = 2
	/*3D scale track (values are stored in [Vector3]s).*/
	TypeScale3d TrackType = 3
	/*Blend shape track.*/
	TypeBlendShape TrackType = 4
	/*Method tracks call functions with given arguments per key.*/
	TypeMethod TrackType = 5
	/*Bezier tracks are used to interpolate a value using custom curves. They can also be used to animate sub-properties of vectors and colors (e.g. alpha value of a [Color]).*/
	TypeBezier TrackType = 6
	/*Audio tracks are used to play an audio stream with either type of [AudioStreamPlayer]. The stream can be trimmed and previewed in the animation.*/
	TypeAudio TrackType = 7
	/*Animation tracks play animations in other [AnimationPlayer] nodes.*/
	TypeAnimation TrackType = 8
)

type UpdateMode

type UpdateMode = gdclass.AnimationUpdateMode //gd:Animation.UpdateMode
const (
	/*Update between keyframes and hold the value.*/
	UpdateContinuous UpdateMode = 0
	/*Update at the keyframes.*/
	UpdateDiscrete UpdateMode = 1
	/*Same as [constant UPDATE_CONTINUOUS] but works as a flag to capture the value of the current object and perform interpolation in some methods. See also [method AnimationMixer.capture], [member AnimationPlayer.playback_auto_capture], and [method AnimationPlayer.play_with_capture].*/
	UpdateCapture UpdateMode = 2
)

Jump to

Keyboard shortcuts

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