virtualx-engine/doc/classes/Animation.xml

634 lines
26 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" ?>
<class name="Animation" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Contains data used to animate everything in the engine.
</brief_description>
<description>
An Animation resource contains data used to animate everything 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]
2018-10-03 04:35:59 +02:00
# This creates an animation that makes the node "Enemy" move to the right by
# 100 pixels in 0.5 seconds.
2018-10-03 04:35:59 +02:00
var animation = Animation.new()
var track_index = animation.add_track(Animation.TYPE_VALUE)
animation.track_set_path(track_index, "Enemy:position:x")
2018-10-03 04:35:59 +02:00
animation.track_insert_key(track_index, 0.0, 0)
animation.track_insert_key(track_index, 0.5, 100)
[/gdscript]
[csharp]
// This creates an animation that makes the node "Enemy" move to the right by
// 100 pixels in 0.5 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, 0.5f, 100);
[/csharp]
[/codeblocks]
2020-03-03 19:21:21 +01:00
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.
</description>
<tutorials>
<link title="Animation documentation index">$DOCS_URL/tutorials/animation/index.html</link>
</tutorials>
<methods>
<method name="add_track">
<return type="int" />
<param index="0" name="type" type="int" enum="Animation.TrackType" />
<param index="1" name="at_position" type="int" default="-1" />
<description>
Adds a track to the Animation.
</description>
</method>
<method name="animation_track_get_key_animation" qualifiers="const">
<return type="StringName" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the animation name at the key identified by [param key_idx]. The [param track_idx] must be the index of an Animation Track.
</description>
</method>
<method name="animation_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="animation" type="StringName" />
<description>
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.
</description>
</method>
<method name="animation_track_set_key_animation">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="animation" type="StringName" />
<description>
Sets the key identified by [param key_idx] to value [param animation]. The [param track_idx] must be the index of an Animation Track.
</description>
</method>
<method name="audio_track_get_key_end_offset" qualifiers="const">
<return type="float" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the end offset of the key identified by [param key_idx]. The [param track_idx] must be the index of an Audio Track.
2020-03-03 19:21:21 +01:00
End offset is the number of seconds cut off at the ending of the audio stream.
</description>
</method>
<method name="audio_track_get_key_start_offset" qualifiers="const">
<return type="float" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the start offset of the key identified by [param key_idx]. The [param track_idx] must be the index of an Audio Track.
2020-03-03 19:21:21 +01:00
Start offset is the number of seconds cut off at the beginning of the audio stream.
</description>
</method>
<method name="audio_track_get_key_stream" qualifiers="const">
<return type="Resource" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the audio stream of the key identified by [param key_idx]. The [param track_idx] must be the index of an Audio Track.
</description>
</method>
<method name="audio_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="stream" type="Resource" />
<param index="3" name="start_offset" type="float" default="0" />
<param index="4" name="end_offset" type="float" default="0" />
<description>
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.
</description>
</method>
<method name="audio_track_set_key_end_offset">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="offset" type="float" />
<description>
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.
</description>
</method>
<method name="audio_track_set_key_start_offset">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="offset" type="float" />
<description>
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.
</description>
</method>
<method name="audio_track_set_key_stream">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="stream" type="Resource" />
<description>
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.
</description>
</method>
<method name="bezier_track_get_key_in_handle" qualifiers="const">
<return type="Vector2" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the in handle of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track.
</description>
</method>
<method name="bezier_track_get_key_out_handle" qualifiers="const">
<return type="Vector2" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the out handle of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track.
</description>
</method>
<method name="bezier_track_get_key_value" qualifiers="const">
<return type="float" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the value of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track.
</description>
</method>
<method name="bezier_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="value" type="float" />
<param index="3" name="in_handle" type="Vector2" default="Vector2(0, 0)" />
<param index="4" name="out_handle" type="Vector2" default="Vector2(0, 0)" />
<description>
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.
</description>
</method>
<method name="bezier_track_interpolate" qualifiers="const">
<return type="float" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<description>
Returns the interpolated value at the given [param time] (in seconds). The [param track_idx] must be the index of a Bezier Track.
</description>
</method>
<method name="bezier_track_set_key_in_handle">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="in_handle" type="Vector2" />
<param index="3" name="balanced_value_time_ratio" type="float" default="1.0" />
<description>
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.
</description>
</method>
<method name="bezier_track_set_key_out_handle">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="out_handle" type="Vector2" />
<param index="3" name="balanced_value_time_ratio" type="float" default="1.0" />
<description>
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.
</description>
</method>
<method name="bezier_track_set_key_value">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="value" type="float" />
<description>
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.
</description>
</method>
<method name="blend_shape_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="amount" type="float" />
<description>
</description>
</method>
<method name="clear">
<return type="void" />
<description>
Clear the animation (clear all tracks and reset all).
</description>
</method>
<method name="compress">
<return type="void" />
<param index="0" name="page_size" type="int" default="8192" />
<param index="1" name="fps" type="int" default="120" />
<param index="2" name="split_tolerance" type="float" default="4.0" />
<description>
</description>
</method>
2017-12-10 00:43:30 +01:00
<method name="copy_track">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="to_animation" type="Animation" />
2017-12-10 00:43:30 +01:00
<description>
Adds a new track that is a copy of the given track from [param to_animation].
2017-12-10 00:43:30 +01:00
</description>
</method>
<method name="find_track" qualifiers="const">
<return type="int" />
<param index="0" name="path" type="NodePath" />
<param index="1" name="type" type="int" enum="Animation.TrackType" />
<description>
Returns the index of the specified track. If the track is not found, return -1.
</description>
</method>
<method name="get_track_count" qualifiers="const">
<return type="int" />
<description>
Returns the amount of tracks in the animation.
</description>
</method>
<method name="method_track_get_key_indices" qualifiers="const">
<return type="PackedInt32Array" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time_sec" type="float" />
<param index="2" name="delta" type="float" />
<description>
Returns all the key indices of a method track, given a position and delta time.
</description>
</method>
<method name="method_track_get_name" qualifiers="const">
<return type="StringName" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the method name of a method track.
</description>
</method>
<method name="method_track_get_params" qualifiers="const">
<return type="Array" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the arguments values to be called on a method track for a given key in a given track.
</description>
</method>
<method name="position_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="position" type="Vector3" />
<description>
</description>
</method>
<method name="remove_track">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<description>
Removes a track by specifying the track index.
</description>
</method>
<method name="rotation_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="rotation" type="Quaternion" />
<description>
</description>
</method>
<method name="scale_track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="scale" type="Vector3" />
<description>
</description>
</method>
<method name="track_find_key" qualifiers="const">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="exact" type="bool" default="false" />
<description>
Finds the key index by time in a given track. Optionally, only find it if the exact time is given.
</description>
</method>
<method name="track_get_interpolation_loop_wrap" qualifiers="const">
<return type="bool" />
<param index="0" name="track_idx" type="int" />
<description>
Returns [code]true[/code] if the track at [param track_idx] wraps the interpolation loop. New tracks wrap the interpolation loop by default.
</description>
</method>
<method name="track_get_interpolation_type" qualifiers="const">
<return type="int" enum="Animation.InterpolationType" />
<param index="0" name="track_idx" type="int" />
<description>
Returns the interpolation type of a given track.
</description>
</method>
<method name="track_get_key_count" qualifiers="const">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<description>
Returns the number of keys in a given track.
</description>
</method>
<method name="track_get_key_time" qualifiers="const">
<return type="float" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the time at which the key is located.
</description>
</method>
<method name="track_get_key_transition" qualifiers="const">
<return type="float" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
2021-01-04 14:33:44 +01:00
Returns the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]).
</description>
</method>
<method name="track_get_key_value" qualifiers="const">
<return type="Variant" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Returns the value of a given key in a given track.
</description>
</method>
<method name="track_get_path" qualifiers="const">
<return type="NodePath" />
<param index="0" name="track_idx" type="int" />
<description>
Gets the path of a track. For more information on the path format, see [method track_set_path].
</description>
</method>
<method name="track_get_type" qualifiers="const">
<return type="int" enum="Animation.TrackType" />
<param index="0" name="track_idx" type="int" />
<description>
Gets the type of a track.
</description>
</method>
<method name="track_insert_key">
<return type="int" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<param index="2" name="key" type="Variant" />
<param index="3" name="transition" type="float" default="1" />
<description>
Inserts a generic key in a given track. Returns the key index.
</description>
</method>
<method name="track_is_compressed" qualifiers="const">
<return type="bool" />
<param index="0" name="track_idx" type="int" />
<description>
</description>
</method>
2017-12-10 00:43:30 +01:00
<method name="track_is_enabled" qualifiers="const">
<return type="bool" />
<param index="0" name="track_idx" type="int" />
2017-12-10 00:43:30 +01:00
<description>
Returns [code]true[/code] if the track at index [param track_idx] is enabled.
2017-12-10 00:43:30 +01:00
</description>
</method>
<method name="track_is_imported" qualifiers="const">
<return type="bool" />
<param index="0" name="track_idx" type="int" />
<description>
Returns [code]true[/code] if the given track is imported. Else, return [code]false[/code].
</description>
</method>
<method name="track_move_down">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<description>
Moves a track down.
</description>
</method>
<method name="track_move_to">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="to_idx" type="int" />
<description>
Changes the index position of track [param track_idx] to the one defined in [param to_idx].
</description>
</method>
<method name="track_move_up">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<description>
Moves a track up.
</description>
</method>
<method name="track_remove_key">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<description>
Removes a key by index in a given track.
</description>
</method>
<method name="track_remove_key_at_time">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time" type="float" />
<description>
Removes a key at [param time] in a given track.
</description>
</method>
2017-12-10 00:43:30 +01:00
<method name="track_set_enabled">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="enabled" type="bool" />
2017-12-10 00:43:30 +01:00
<description>
Enables/disables the given track. Tracks are enabled by default.
2017-12-10 00:43:30 +01:00
</description>
</method>
<method name="track_set_imported">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="imported" type="bool" />
<description>
Sets the given track as imported or not.
</description>
</method>
<method name="track_set_interpolation_loop_wrap">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="interpolation" type="bool" />
<description>
If [code]true[/code], the track at [param track_idx] wraps the interpolation loop.
</description>
</method>
<method name="track_set_interpolation_type">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="interpolation" type="int" enum="Animation.InterpolationType" />
<description>
Sets the interpolation type of a given track.
</description>
</method>
2019-06-01 12:34:29 +02:00
<method name="track_set_key_time">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="time" type="float" />
<description>
Sets the time of an existing key.
</description>
</method>
2019-06-01 12:34:29 +02:00
<method name="track_set_key_transition">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key_idx" type="int" />
<param index="2" name="transition" type="float" />
<description>
2021-01-04 14:33:44 +01:00
Sets the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]).
</description>
</method>
2019-06-01 12:34:29 +02:00
<method name="track_set_key_value">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="key" type="int" />
<param index="2" name="value" type="Variant" />
2019-05-31 00:39:00 +02:00
<description>
Sets the value of an existing key.
2019-05-31 00:39:00 +02:00
</description>
</method>
<method name="track_set_path">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="path" type="NodePath" />
<description>
Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the parent node of the 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].
</description>
</method>
<method name="track_swap">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="with_idx" type="int" />
<description>
Swaps the track [param track_idx]'s index position with the track [param with_idx].
</description>
</method>
<method name="value_track_get_key_indices" qualifiers="const">
<return type="PackedInt32Array" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time_sec" type="float" />
<param index="2" name="delta" type="float" />
<description>
Returns all the key indices of a value track, given a position and delta time.
</description>
</method>
<method name="value_track_get_update_mode" qualifiers="const">
<return type="int" enum="Animation.UpdateMode" />
<param index="0" name="track_idx" type="int" />
<description>
Returns the update mode of a value track.
</description>
</method>
2020-10-09 15:04:15 +02:00
<method name="value_track_interpolate" qualifiers="const">
<return type="Variant" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="time_sec" type="float" />
<description>
Returns the interpolated value at the given time (in seconds). The [param track_idx] must be the index of a value track.
</description>
</method>
2020-10-09 15:04:15 +02:00
<method name="value_track_set_update_mode">
<return type="void" />
<param index="0" name="track_idx" type="int" />
<param index="1" name="mode" type="int" enum="Animation.UpdateMode" />
<description>
2020-10-09 15:04:15 +02:00
Sets the update mode (see [enum UpdateMode]) of a value track.
</description>
</method>
</methods>
2018-01-11 23:38:35 +01:00
<members>
<member name="length" type="float" setter="set_length" getter="get_length" default="1.0">
The total length of the animation (in seconds).
[b]Note:[/b] Length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.
2018-01-11 23:38:35 +01:00
</member>
2021-10-15 15:25:00 +02:00
<member name="loop_mode" type="int" setter="set_loop_mode" getter="get_loop_mode" enum="Animation.LoopMode" default="0">
Determines the behavior of both ends of the animation timeline during animation playback. This is used for correct interpolation of animation cycles, and for hinting the player that it must restart the animation.
2018-01-11 23:38:35 +01:00
</member>
<member name="step" type="float" setter="set_step" getter="get_step" default="0.1">
2018-01-11 23:38:35 +01:00
The animation step value.
</member>
</members>
<signals>
<signal name="tracks_changed">
<description>
2020-03-03 19:21:21 +01:00
Emitted when there's a change in the list of tracks, e.g. tracks are added, moved or have changed paths.
</description>
</signal>
</signals>
<constants>
2017-11-24 23:16:30 +01:00
<constant name="TYPE_VALUE" value="0" enum="TrackType">
Value tracks set values in node properties, but only those which can be Interpolated.
</constant>
<constant name="TYPE_POSITION_3D" value="1" enum="TrackType">
</constant>
<constant name="TYPE_ROTATION_3D" value="2" enum="TrackType">
</constant>
<constant name="TYPE_SCALE_3D" value="3" enum="TrackType">
</constant>
<constant name="TYPE_BLEND_SHAPE" value="4" enum="TrackType">
</constant>
<constant name="TYPE_METHOD" value="5" enum="TrackType">
Method tracks call functions with given arguments per key.
</constant>
<constant name="TYPE_BEZIER" value="6" enum="TrackType">
2020-03-03 19:21:21 +01:00
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]).
</constant>
<constant name="TYPE_AUDIO" value="7" enum="TrackType">
2020-03-03 19:21:21 +01:00
Audio tracks are used to play an audio stream with either type of [AudioStreamPlayer]. The stream can be trimmed and previewed in the animation.
</constant>
<constant name="TYPE_ANIMATION" value="8" enum="TrackType">
2020-03-03 19:21:21 +01:00
Animation tracks play animations in other [AnimationPlayer] nodes.
</constant>
2017-11-24 23:16:30 +01:00
<constant name="INTERPOLATION_NEAREST" value="0" enum="InterpolationType">
No interpolation (nearest value).
</constant>
2017-11-24 23:16:30 +01:00
<constant name="INTERPOLATION_LINEAR" value="1" enum="InterpolationType">
Linear interpolation.
</constant>
2017-11-24 23:16:30 +01:00
<constant name="INTERPOLATION_CUBIC" value="2" enum="InterpolationType">
Cubic interpolation.
</constant>
<constant name="INTERPOLATION_LINEAR_ANGLE" value="3" enum="InterpolationType">
Linear interpolation with shortest path rotation.
[b]Note:[/b] The result value is always normalized and may not match the key value.
</constant>
<constant name="INTERPOLATION_CUBIC_ANGLE" value="4" enum="InterpolationType">
Cubic interpolation with shortest path rotation.
[b]Note:[/b] The result value is always normalized and may not match the key value.
</constant>
2017-11-24 23:16:30 +01:00
<constant name="UPDATE_CONTINUOUS" value="0" enum="UpdateMode">
Update between keyframes.
</constant>
2017-11-24 23:16:30 +01:00
<constant name="UPDATE_DISCRETE" value="1" enum="UpdateMode">
Update at the keyframes and hold the value.
</constant>
2017-11-24 23:16:30 +01:00
<constant name="UPDATE_TRIGGER" value="2" enum="UpdateMode">
Update at the keyframes.
</constant>
<constant name="UPDATE_CAPTURE" value="3" enum="UpdateMode">
2020-03-03 19:21:21 +01:00
Same as linear interpolation, but also interpolates from the current value (i.e. dynamically at runtime) if the first key isn't at 0 seconds.
</constant>
2021-10-15 15:25:00 +02:00
<constant name="LOOP_NONE" value="0" enum="LoopMode">
At both ends of the animation, the animation will stop playing.
</constant>
<constant name="LOOP_LINEAR" value="1" enum="LoopMode">
At both ends of the animation, the animation will be repeated without changing the playback direction.
</constant>
<constant name="LOOP_PINGPONG" value="2" enum="LoopMode">
Repeats playback and reverse playback at both ends of the animation.
</constant>
</constants>
</class>