Up to date

This page is up to date for Godot 4.0. If you still find outdated information, please open an issue.

AnimationNodeOneShot

Inherits: AnimationNodeSync < AnimationNode < Resource < RefCounted < Object

Plays an animation once in an AnimationNodeBlendTree.

Description

A resource to add to an AnimationNodeBlendTree. This 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.

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 request value to ONE_SHOT_REQUEST_NONE.

GDScriptC#

  1. # Play child animation connected to "shot" port.
  2. animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
  3. # Alternative syntax (same result as above).
  4. animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE
  5. # Abort child animation connected to "shot" port.
  6. animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
  7. # Alternative syntax (same result as above).
  8. animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT
  9. # Get current state (read-only).
  10. animation_tree.get("parameters/OneShot/active"))
  11. # Alternative syntax (same result as above).
  12. animation_tree["parameters/OneShot/active"]
  1. // Play child animation connected to "shot" port.
  2. animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.Fire);
  3. // Abort child animation connected to "shot" port.
  4. animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.Abort);
  5. // Get current state (read-only).
  6. animationTree.Get("parameters/OneShot/active");

Tutorials

Properties

bool

autorestart

false

float

autorestart_delay

1.0

float

autorestart_random_delay

0.0

float

fadein_time

0.0

float

fadeout_time

0.0

MixMode

mix_mode

0


Enumerations

enum OneShotRequest:

OneShotRequest ONE_SHOT_REQUEST_NONE = 0

The default state of the request. Nothing is done.

OneShotRequest ONE_SHOT_REQUEST_FIRE = 1

The request to play the animation connected to “shot” port.

OneShotRequest ONE_SHOT_REQUEST_ABORT = 2

The request to stop the animation connected to “shot” port.


enum MixMode:

MixMode MIX_MODE_BLEND = 0

Blends two animations. See also AnimationNodeBlend2.

MixMode MIX_MODE_ADD = 1

Blends two animations additively. See also AnimationNodeAdd2.


Property Descriptions

bool autorestart = false

  • void set_autorestart ( bool value )

  • bool has_autorestart ( )

If true, the sub-animation will restart automatically after finishing.

In other words, to start auto restarting, the animation must be played once with the ONE_SHOT_REQUEST_FIRE request. The ONE_SHOT_REQUEST_ABORT request stops the auto restarting, but it does not disable the autorestart itself. So, the ONE_SHOT_REQUEST_FIRE request will start auto restarting again.


float autorestart_delay = 1.0

  • void set_autorestart_delay ( float value )

  • float get_autorestart_delay ( )

The delay after which the automatic restart is triggered, in seconds.


float autorestart_random_delay = 0.0

  • void set_autorestart_random_delay ( float value )

  • float get_autorestart_random_delay ( )

If autorestart is true, a random additional delay (in seconds) between 0 and this value will be added to autorestart_delay.


float fadein_time = 0.0

  • void set_fadein_time ( float value )

  • float get_fadein_time ( )

The fade-in duration. For example, setting this to 1.0 for a 5 second length animation will produce a crossfade that starts at 0 second and ends at 1 second during the animation.


float fadeout_time = 0.0

  • void set_fadeout_time ( float value )

  • float get_fadeout_time ( )

The fade-out duration. For example, setting this to 1.0 for a 5 second length animation will produce a crossfade that starts at 4 second and ends at 5 second during the animation.


MixMode mix_mode = 0

The blend type.