AnimationNodeOneShot

继承: AnimationNodeSync < AnimationNode < Resource < RefCounted < Object

Plays an animation once in an AnimationNodeBlendTree.

描述

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.

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.


    # Play child animation connected to "shot" port.
    animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
    # Alternative syntax (same result as above).
    animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE
    
    # Abort child animation connected to "shot" port.
    animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
    # Alternative syntax (same result as above).
    animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT
    
    # Abort child animation with fading out connected to "shot" port.
    animation_tree.set("parameters/OneShot/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FADE_OUT)
    # Alternative syntax (same result as above).
    animation_tree["parameters/OneShot/request"] = AnimationNodeOneShot.ONE_SHOT_REQUEST_FADE_OUT
    
    # Get current state (read-only).
    animation_tree.get("parameters/OneShot/active")
    # Alternative syntax (same result as above).
    animation_tree["parameters/OneShot/active"]
    
    # Get current internal state (read-only).
    animation_tree.get("parameters/OneShot/internal_active")
    # Alternative syntax (same result as above).
    animation_tree["parameters/OneShot/internal_active"]

    // Play child animation connected to "shot" port.
    animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.Fire);
    
    // Abort child animation connected to "shot" port.
    animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.Abort);
    
    // Abort child animation with fading out connected to "shot" port.
    animationTree.Set("parameters/OneShot/request", (int)AnimationNodeOneShot.OneShotRequest.FadeOut);
    
    // Get current state (read-only).
    animationTree.Get("parameters/OneShot/active");
    
    // Get current internal state (read-only).
    animationTree.Get("parameters/OneShot/internal_active");

属性


枚举

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.

OneShotRequest ONE_SHOT_REQUEST_FADE_OUT = 3

The request to fade out 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.


属性说明

bool autorestart = false

  • void set_autorestart ( value: bool )
  • 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 ( value: float )
  • 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 ( value: float )
  • 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.


bool break_loop_at_end = false

  • void set_break_loop_at_end ( value: bool )
  • bool is_loop_broken_at_end ( )

If true, breaks the loop at the end of the loop cycle for transition, even if the animation is looping.


Curve fadein_curve

  • void set_fadein_curve ( value: Curve )
  • Curve get_fadein_curve ( )

Determines how cross-fading between animations is eased. If empty, the transition will be linear.


float fadein_time = 0.0

  • void set_fadein_time ( value: float )
  • float get_fadein_time ( )

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

Note: AnimationNodeOneShot transitions the current state after the end of the fading. When AnimationNodeOutput is considered as the most upstream, so the fadein_time is scaled depending on the downstream delta. For example, if this value is set to 1.0 and a AnimationNodeTimeScale with a value of 2.0 is chained downstream, the actual processing time will be 0.5 second.


Curve fadeout_curve

  • void set_fadeout_curve ( value: Curve )
  • Curve get_fadeout_curve ( )

Determines how cross-fading between animations is eased. If empty, the transition will be linear.


float fadeout_time = 0.0

  • void set_fadeout_time ( value: float )
  • float get_fadeout_time ( )

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

Note: AnimationNodeOneShot transitions the current state after the end of the fading. When AnimationNodeOutput is considered as the most upstream, so the fadeout_time is scaled depending on the downstream delta. For example, if this value is set to 1.0 and an AnimationNodeTimeScale with a value of 2.0 is chained downstream, the actual processing time will be 0.5 second.


MixMode mix_mode = 0

The blend type.

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。