0.2.0-dev Download ZIP
124 lines ·7.3 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="AnimationNodeOneShot" inherits="AnimationNodeSync" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Plays an animation once in an [AnimationNodeBlendTree]. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | A resource to add to an [AnimationNodeBlendTree]. This animation node will execute a sub-animation and return once it finishes. Blend times for fading in and out can be customized, as well as filters. |
| 8 | After setting the request and changing the animation playback, the one-shot node automatically clears the request on the next process frame by setting its [code]request[/code] value to [constant ONE_SHOT_REQUEST_NONE]. |
| 9 | [codeblocks] |
| 10 | [gdscript] |
| 11 | # Play child animation connected to "shot" port. |
| 12 | animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE) |
| 13 | # Alternative syntax (same result as above). |
| 14 | animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE |
| 15 | |
| 16 | # Abort child animation connected to "shot" port. |
| 17 | animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT) |
| 18 | # Alternative syntax (same result as above). |
| 19 | animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT |
| 20 | |
| 21 | # Abort child animation with fading out connected to "shot" port. |
| 22 | animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FADE_OUT) |
| 23 | # Alternative syntax (same result as above). |
| 24 | animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_FADE_OUT |
| 25 | |
| 26 | # Get current state (read-only). |
| 27 | animation_tree.get("parameters/OneShot/active") |
| 28 | # Alternative syntax (same result as above). |
| 29 | animation_tree["parameters/OneShot/active"] |
| 30 | |
| 31 | # Get current internal state (read-only). |
| 32 | animation_tree.get("parameters/OneShot/internal_active") |
| 33 | # Alternative syntax (same result as above). |
| 34 | animation_tree["parameters/OneShot/internal_active"] |
| 35 | [/gdscript] |
| 36 | [csharp] |
| 37 | // Play child animation connected to "shot" port. |
| 38 | animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.Fire); |
| 39 | |
| 40 | // Abort child animation connected to "shot" port. |
| 41 | animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.Abort); |
| 42 | |
| 43 | // Abort child animation with fading out connected to "shot" port. |
| 44 | animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.FadeOut); |
| 45 | |
| 46 | // Get current state (read-only). |
| 47 | animationTree.Get("parameters/OneShot/active"); |
| 48 | |
| 49 | // Get current internal state (read-only). |
| 50 | animationTree.Get("parameters/OneShot/internal_active"); |
| 51 | [/csharp] |
| 52 | [/codeblocks] |
| 53 | Optionally, signals can be used by setting an [AnimationNodeObserverOneShot] through [AnimationTree]. |
| 54 | [codeblocks] |
| 55 | [gdscript] |
| 56 | var observer = tree.get("parameters/OneShot/observer") |
| 57 | observer.started.connect(on_one_shot_started) |
| 58 | [/gdscript] |
| 59 | [csharp] |
| 60 | var observer = animationTree.Get("parameters/OneShot/observer").As<AnimationNodeObserverOneShot>(); |
| 61 | observer.Started += OnOneShotStarted; |
| 62 | [/csharp] |
| 63 | [/codeblocks] |
| 64 | </description> |
| 65 | <tutorials> |
| 66 | <link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link> |
| 67 | <link title="Third Person Shooter (TPS) Demo">https://godotengine.org/asset-library/asset/2710</link> |
| 68 | </tutorials> |
| 69 | <members> |
| 70 | <member name="abort_on_reset" type="bool" setter="set_abort_on_reset" getter="is_aborted_on_reset" default="false"> |
| 71 | If [code]true[/code], the sub-animation will abort if resumed with a reset after a prior interruption. |
| 72 | </member> |
| 73 | <member name="autorestart" type="bool" setter="set_autorestart" getter="has_autorestart" default="false"> |
| 74 | If [code]true[/code], the sub-animation will restart automatically after finishing. |
| 75 | In other words, to start auto restarting, the animation must be played once with the [constant ONE_SHOT_REQUEST_FIRE] request. The [constant ONE_SHOT_REQUEST_ABORT] request stops the auto restarting, but it does not disable the [member autorestart] itself. So, the [constant ONE_SHOT_REQUEST_FIRE] request will start auto restarting again. |
| 76 | </member> |
| 77 | <member name="autorestart_delay" type="float" setter="set_autorestart_delay" getter="get_autorestart_delay" default="1.0"> |
| 78 | The delay after which the automatic restart is triggered, in seconds. |
| 79 | </member> |
| 80 | <member name="autorestart_random_delay" type="float" setter="set_autorestart_random_delay" getter="get_autorestart_random_delay" default="0.0"> |
| 81 | If [member autorestart] is [code]true[/code], a random additional delay (in seconds) between 0 and this value will be added to [member autorestart_delay]. |
| 82 | </member> |
| 83 | <member name="break_loop_at_end" type="bool" setter="set_break_loop_at_end" getter="is_loop_broken_at_end" default="false"> |
| 84 | If [code]true[/code], breaks the loop at the end of the loop cycle for transition, even if the animation is looping. |
| 85 | </member> |
| 86 | <member name="fadein_curve" type="Curve" setter="set_fadein_curve" getter="get_fadein_curve"> |
| 87 | Determines how cross-fading between animations is eased. If empty, the transition will be linear. Should be a unit [Curve]. |
| 88 | </member> |
| 89 | <member name="fadein_time" type="float" setter="set_fadein_time" getter="get_fadein_time" default="0.0"> |
| 90 | The fade-in duration. For example, setting this to [code]1.0[/code] for a 5 second length animation will produce a cross-fade that starts at 0 second and ends at 1 second during the animation. |
| 91 | [b]Note:[/b] [AnimationNodeOneShot] transitions the current state after the fading has finished. |
| 92 | </member> |
| 93 | <member name="fadeout_curve" type="Curve" setter="set_fadeout_curve" getter="get_fadeout_curve"> |
| 94 | Determines how cross-fading between animations is eased. If empty, the transition will be linear. Should be a unit [Curve]. |
| 95 | </member> |
| 96 | <member name="fadeout_time" type="float" setter="set_fadeout_time" getter="get_fadeout_time" default="0.0"> |
| 97 | The fade-out duration. For example, setting this to [code]1.0[/code] for a 5 second length animation will produce a cross-fade that starts at 4 second and ends at 5 second during the animation. |
| 98 | [b]Note:[/b] [AnimationNodeOneShot] transitions the current state after the fading has finished. |
| 99 | </member> |
| 100 | <member name="mix_mode" type="int" setter="set_mix_mode" getter="get_mix_mode" enum="AnimationNodeOneShot.MixMode" default="0"> |
| 101 | The blend type. |
| 102 | </member> |
| 103 | </members> |
| 104 | <constants> |
| 105 | <constant name="ONE_SHOT_REQUEST_NONE" value="0" enum="OneShotRequest"> |
| 106 | The default state of the request. Nothing is done. |
| 107 | </constant> |
| 108 | <constant name="ONE_SHOT_REQUEST_FIRE" value="1" enum="OneShotRequest"> |
| 109 | The request to play the animation connected to "shot" port. |
| 110 | </constant> |
| 111 | <constant name="ONE_SHOT_REQUEST_ABORT" value="2" enum="OneShotRequest"> |
| 112 | The request to stop the animation connected to "shot" port. |
| 113 | </constant> |
| 114 | <constant name="ONE_SHOT_REQUEST_FADE_OUT" value="3" enum="OneShotRequest"> |
| 115 | The request to fade out the animation connected to "shot" port. |
| 116 | </constant> |
| 117 | <constant name="MIX_MODE_BLEND" value="0" enum="MixMode"> |
| 118 | Blends two animations. See also [AnimationNodeBlend2]. |
| 119 | </constant> |
| 120 | <constant name="MIX_MODE_ADD" value="1" enum="MixMode"> |
| 121 | Blends two animations additively. See also [AnimationNodeAdd2]. |
| 122 | </constant> |
| 123 | </constants> |
| 124 | </class> |