Documentation ¶
Overview ¶
Package Animation provides methods for working with Animation object instances.
Index ¶
- type Advanced
- type Any
- type FindMode
- type Instance
- func (self Instance) AddTrack(atype gdclass.AnimationTrackType) int
- func (self Instance) AnimationTrackGetKeyAnimation(track_idx int, key_idx int) string
- func (self Instance) AnimationTrackInsertKey(track_idx int, time Float.X, animation string) int
- func (self Instance) AnimationTrackSetKeyAnimation(track_idx int, key_idx int, animation string)
- func (self Instance) AsAnimation() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) AudioTrackGetKeyEndOffset(track_idx int, key_idx int) Float.X
- func (self Instance) AudioTrackGetKeyStartOffset(track_idx int, key_idx int) Float.X
- func (self Instance) AudioTrackGetKeyStream(track_idx int, key_idx int) [1]gdclass.Resource
- func (self Instance) AudioTrackInsertKey(track_idx int, time Float.X, stream [1]gdclass.Resource) int
- func (self Instance) AudioTrackIsUseBlend(track_idx int) bool
- func (self Instance) AudioTrackSetKeyEndOffset(track_idx int, key_idx int, offset Float.X)
- func (self Instance) AudioTrackSetKeyStartOffset(track_idx int, key_idx int, offset Float.X)
- func (self Instance) AudioTrackSetKeyStream(track_idx int, key_idx int, stream [1]gdclass.Resource)
- func (self Instance) AudioTrackSetUseBlend(track_idx int, enable bool)
- func (self Instance) BezierTrackGetKeyInHandle(track_idx int, key_idx int) Vector2.XY
- func (self Instance) BezierTrackGetKeyOutHandle(track_idx int, key_idx int) Vector2.XY
- func (self Instance) BezierTrackGetKeyValue(track_idx int, key_idx int) Float.X
- func (self Instance) BezierTrackInsertKey(track_idx int, time Float.X, value Float.X) int
- func (self Instance) BezierTrackInterpolate(track_idx int, time Float.X) Float.X
- func (self Instance) BezierTrackSetKeyInHandle(track_idx int, key_idx int, in_handle Vector2.XY)
- func (self Instance) BezierTrackSetKeyOutHandle(track_idx int, key_idx int, out_handle Vector2.XY)
- func (self Instance) BezierTrackSetKeyValue(track_idx int, key_idx int, value Float.X)
- func (self Instance) BlendShapeTrackInsertKey(track_idx int, time Float.X, amount Float.X) int
- func (self Instance) BlendShapeTrackInterpolate(track_idx int, time_sec Float.X) Float.X
- func (self Instance) CaptureIncluded() bool
- func (self Instance) Clear()
- func (self Instance) Compress()
- func (self Instance) CopyTrack(track_idx int, to_animation [1]gdclass.Animation)
- func (self Instance) FindTrack(path string, atype gdclass.AnimationTrackType) int
- func (self Instance) GetTrackCount() int
- func (self Instance) Length() Float.X
- func (self Instance) LoopMode() gdclass.AnimationLoopMode
- func (self Instance) MethodTrackGetName(track_idx int, key_idx int) string
- func (self Instance) MethodTrackGetParams(track_idx int, key_idx int) []any
- func (self Instance) PositionTrackInsertKey(track_idx int, time Float.X, position Vector3.XYZ) int
- func (self Instance) PositionTrackInterpolate(track_idx int, time_sec Float.X) Vector3.XYZ
- func (self Instance) RemoveTrack(track_idx int)
- func (self Instance) RotationTrackInsertKey(track_idx int, time Float.X, rotation Quaternion.IJKX) int
- func (self Instance) RotationTrackInterpolate(track_idx int, time_sec Float.X) Quaternion.IJKX
- func (self Instance) ScaleTrackInsertKey(track_idx int, time Float.X, scale Vector3.XYZ) int
- func (self Instance) ScaleTrackInterpolate(track_idx int, time_sec Float.X) Vector3.XYZ
- func (self Instance) SetLength(value Float.X)
- func (self Instance) SetLoopMode(value gdclass.AnimationLoopMode)
- func (self Instance) SetStep(value Float.X)
- func (self Instance) Step() Float.X
- func (self Instance) TrackFindKey(track_idx int, time Float.X) int
- func (self Instance) TrackGetInterpolationLoopWrap(track_idx int) bool
- func (self Instance) TrackGetInterpolationType(track_idx int) gdclass.AnimationInterpolationType
- func (self Instance) TrackGetKeyCount(track_idx int) int
- func (self Instance) TrackGetKeyTime(track_idx int, key_idx int) Float.X
- func (self Instance) TrackGetKeyTransition(track_idx int, key_idx int) Float.X
- func (self Instance) TrackGetKeyValue(track_idx int, key_idx int) any
- func (self Instance) TrackGetPath(track_idx int) string
- func (self Instance) TrackGetType(track_idx int) gdclass.AnimationTrackType
- func (self Instance) TrackInsertKey(track_idx int, time Float.X, key any) int
- func (self Instance) TrackIsCompressed(track_idx int) bool
- func (self Instance) TrackIsEnabled(track_idx int) bool
- func (self Instance) TrackIsImported(track_idx int) bool
- func (self Instance) TrackMoveDown(track_idx int)
- func (self Instance) TrackMoveTo(track_idx int, to_idx int)
- func (self Instance) TrackMoveUp(track_idx int)
- func (self Instance) TrackRemoveKey(track_idx int, key_idx int)
- func (self Instance) TrackRemoveKeyAtTime(track_idx int, time Float.X)
- func (self Instance) TrackSetEnabled(track_idx int, enabled bool)
- func (self Instance) TrackSetImported(track_idx int, imported bool)
- func (self Instance) TrackSetInterpolationLoopWrap(track_idx int, interpolation bool)
- func (self Instance) TrackSetInterpolationType(track_idx int, interpolation gdclass.AnimationInterpolationType)
- func (self Instance) TrackSetKeyTime(track_idx int, key_idx int, time Float.X)
- func (self Instance) TrackSetKeyTransition(track_idx int, key_idx int, transition Float.X)
- func (self Instance) TrackSetKeyValue(track_idx int, key int, value any)
- func (self Instance) TrackSetPath(track_idx int, path string)
- func (self Instance) TrackSwap(track_idx int, with_idx int)
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) ValueTrackGetUpdateMode(track_idx int) gdclass.AnimationUpdateMode
- func (self Instance) ValueTrackInterpolate(track_idx int, time_sec Float.X) any
- func (self Instance) ValueTrackSetUpdateMode(track_idx int, mode gdclass.AnimationUpdateMode)
- func (self Instance) Virtual(name string) reflect.Value
- type InterpolationType
- type LoopMode
- type LoopedFlag
- type TrackType
- type UpdateMode
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 FindMode ¶
type FindMode = gdclass.AnimationFindMode //gd:Animation.FindMode
type Instance ¶
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 (Instance) AddTrack ¶
func (self Instance) AddTrack(atype gdclass.AnimationTrackType) int
Adds a track to the Animation.
func (Instance) AnimationTrackGetKeyAnimation ¶
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 ¶
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 ¶
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 (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) AudioTrackGetKeyEndOffset ¶
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 ¶
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 ¶
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 ¶
Returns [code]true[/code] if the track at [param track_idx] will be blended with other animations.
func (Instance) AudioTrackSetKeyEndOffset ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Inserts a key in a given blend shape track. Returns the key index.
func (Instance) BlendShapeTrackInterpolate ¶
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 (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 ¶
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 ¶
Returns the amount of tracks in the animation.
func (Instance) LoopMode ¶
func (self Instance) LoopMode() gdclass.AnimationLoopMode
func (Instance) MethodTrackGetName ¶
Returns the method name of a method track.
func (Instance) MethodTrackGetParams ¶
Returns the arguments values to be called on a method track for a given key in a given track.
func (Instance) PositionTrackInsertKey ¶
Inserts a key in a given 3D position track. Returns the key index.
func (Instance) PositionTrackInterpolate ¶
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 ¶
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 ¶
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 ¶
Inserts a key in a given 3D scale track. Returns the key index.
func (Instance) ScaleTrackInterpolate ¶
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) SetLoopMode ¶
func (self Instance) SetLoopMode(value gdclass.AnimationLoopMode)
func (Instance) TrackFindKey ¶
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 ¶
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 ¶
Returns the number of keys in a given track.
func (Instance) TrackGetKeyTime ¶
Returns the time at which the key is located.
func (Instance) TrackGetKeyTransition ¶
Returns the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]).
func (Instance) TrackGetKeyValue ¶
Returns the value of a given key in a given track.
func (Instance) TrackGetPath ¶
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 ¶
Inserts a generic key in a given track. Returns the key index.
func (Instance) TrackIsCompressed ¶
Returns [code]true[/code] if the track is compressed, [code]false[/code] otherwise. See also [method compress].
func (Instance) TrackIsEnabled ¶
Returns [code]true[/code] if the track at index [param track_idx] is enabled.
func (Instance) TrackIsImported ¶
Returns [code]true[/code] if the given track is imported. Else, return [code]false[/code].
func (Instance) TrackMoveDown ¶
Moves a track down.
func (Instance) TrackMoveTo ¶
Changes the index position of track [param track_idx] to the one defined in [param to_idx].
func (Instance) TrackRemoveKey ¶
Removes a key by index in a given track.
func (Instance) TrackRemoveKeyAtTime ¶
Removes a key at [param time] in a given track.
func (Instance) TrackSetEnabled ¶
Enables/disables the given track. Tracks are enabled by default.
func (Instance) TrackSetImported ¶
Sets the given track as imported or not.
func (Instance) TrackSetInterpolationLoopWrap ¶
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 ¶
Sets the time of an existing key.
func (Instance) TrackSetKeyTransition ¶
Sets the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]).
func (Instance) TrackSetKeyValue ¶
Sets the value of an existing key.
func (Instance) TrackSetPath ¶
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 ¶
Swaps the track [param track_idx]'s index position with the track [param with_idx].
func (*Instance) UnsafePointer ¶
func (Instance) ValueTrackGetUpdateMode ¶
func (self Instance) ValueTrackGetUpdateMode(track_idx int) gdclass.AnimationUpdateMode
Returns the update mode of a value track.
func (Instance) ValueTrackInterpolate ¶
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.
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 )