Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

AnimationNodeOneShot

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

在 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"]

Optionally, signals can be used by setting an AnimationNodeObserverOneShot through AnimationTree.

var observer = tree.get("parameters/OneShot/observer")
observer.started.connect(on_one_shot_started)

教學

屬性

bool

abort_on_reset

false

bool

autorestart

false

float

autorestart_delay

1.0

float

autorestart_random_delay

0.0

bool

break_loop_at_end

false

Curve

fadein_curve

float

fadein_time

0.0

Curve

fadeout_curve

float

fadeout_time

0.0

MixMode

mix_mode

0


列舉

enum OneShotRequest: 🔗

OneShotRequest ONE_SHOT_REQUEST_NONE = 0

請求的預設狀態,不執行任何操作。

OneShotRequest ONE_SHOT_REQUEST_FIRE = 1

播放連接到「shot」埠之動畫的請求。

OneShotRequest ONE_SHOT_REQUEST_ABORT = 2

停止連接到「shot」埠之動畫的請求。

OneShotRequest ONE_SHOT_REQUEST_FADE_OUT = 3

淡出連接到「shot」埠之動畫的請求。


enum MixMode: 🔗

MixMode MIX_MODE_BLEND = 0

混合兩個動畫。另請參見 AnimationNodeBlend2。

MixMode MIX_MODE_ADD = 1

以加成方式混合兩個動畫。另請參見 AnimationNodeAdd2。


屬性說明

bool abort_on_reset = false 🔗

  • void set_abort_on_reset(value: bool)

  • bool is_aborted_on_reset()

如果為 true,則子動畫在先前中斷後使用重設恢復時,子動畫將會中止。


bool autorestart = false 🔗

  • void set_autorestart(value: bool)

  • bool has_autorestart()

如果為 true,子動畫結束後會自動重新開始。

換句話說,要開始自動重新啟動,必須使用 ONE_SHOT_REQUEST_FIRE 請求播放一次動畫。ONE_SHOT_REQUEST_ABORT 請求停止自動重新啟動,但它不會停用 autorestart 本身。因此,ONE_SHOT_REQUEST_FIRE 請求將再次開始自動重新啟動。


float autorestart_delay = 1.0 🔗

  • void set_autorestart_delay(value: float)

  • float get_autorestart_delay()

觸發自動重新啟動的延遲時間,以秒為單位。


float autorestart_random_delay = 0.0 🔗

  • void set_autorestart_random_delay(value: float)

  • float get_autorestart_random_delay()

如果 autorestart 為 true,則介於0和此值之間的隨機附加延遲(以秒為單位)將新增到 autorestart_delay。


bool break_loop_at_end = false 🔗

  • void set_break_loop_at_end(value: bool)

  • bool is_loop_broken_at_end()

如果為 true,即使動畫設定為循環,也會在本迴圈結束時中斷迴圈以進行轉場。


Curve fadein_curve 🔗

  • void set_fadein_curve(value: Curve)

  • Curve get_fadein_curve()

決定動畫交叉淡入淡出的緩動方式。若留空則為線性過渡。應為單位 Curve。


float fadein_time = 0.0 🔗

  • void set_fadein_time(value: float)

  • float get_fadein_time()

淡入持續時間。例如,對長度 5 秒的動畫將此值設為 1.0,會產生從 0 秒開始至 1 秒結束的交叉淡入。

注意: AnimationNodeOneShot 會在淡入結束後才切換目前狀態。


Curve fadeout_curve 🔗

  • void set_fadeout_curve(value: Curve)

  • Curve get_fadeout_curve()

決定動畫交叉淡入淡出的緩動方式。若留空則為線性過渡。應為單位 Curve。


float fadeout_time = 0.0 🔗

  • void set_fadeout_time(value: float)

  • float get_fadeout_time()

淡出持續時間。例如,對長度 5 秒的動畫將此值設為 1.0,會產生從 4 秒開始至 5 秒結束的交叉淡出。

注意: AnimationNodeOneShot 會在淡出結束後才切換目前狀態。


MixMode mix_mode = 0 🔗

混合型別。