AnimationNode
繼承: Resource < RefCounted < Object
被繼承: AnimationNodeExtension, AnimationNodeOutput, AnimationNodeSync, AnimationNodeTimeScale, AnimationNodeTimeSeek, AnimationRootNode
AnimationTree 節點的基底類別,與場景節點無關。
說明
用於 AnimationTree 節點的基礎資源。通常不會直接使用,但你可以建立自訂節點並撰寫自己的混合公式。
若要建立主要用於 AnimationNodeBlendTree 的動畫節點,請繼承本類;否則應使用 AnimationRootNode。
你可以作為唯讀參數存取時間資訊,該資訊已於前一影格為所有節點(除 AnimationNodeOutput 外)處理並儲存。
注意: 當一個 AnimationNode 擁有多個輸入時,最終採用哪個輸入的時間資訊,取決於該動畫節點的類型。
var current_length = $AnimationTree["parameters/AnimationNodeName/current_length"]
var current_position = $AnimationTree["parameters/AnimationNodeName/current_position"]
var current_delta = $AnimationTree["parameters/AnimationNodeName/current_delta"]
教學
屬性
方法
_get_caption() virtual const |
|
_get_child_by_name(name: StringName) virtual const |
|
_get_child_nodes() virtual const |
|
_get_parameter_default_value(parameter: StringName) virtual const |
|
_get_parameter_list() virtual const |
|
_has_filter() virtual const |
|
_is_parameter_read_only(parameter: StringName) virtual const |
|
_process(time: float, seek: bool, is_external_seeking: bool, test_only: bool) virtual |
|
void |
blend_animation(animation: StringName, time: float, delta: float, seeked: bool, is_external_seeking: bool, blend: float, looped_flag: LoopedFlag = 0) |
blend_input(input_index: int, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) |
|
blend_node(name: StringName, node: AnimationNode, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) |
|
find_input(name: String) const |
|
get_input_count() const |
|
get_input_name(input: int) const |
|
get_parameter(name: StringName) const |
|
is_path_filtered(path: NodePath) const |
|
is_process_testing() const |
|
void |
remove_input(index: int) |
void |
set_filter_path(path: NodePath, enable: bool) |
set_input_name(input: int, name: String) |
|
void |
set_parameter(name: StringName, value: Variant) |
訊號
animation_node_removed(object_id: int, name: String) 🔗
繼承此類且具有內部樹的節點在其中一個動畫節點被移除時會發出此訊號。發出者包含 AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine 與 AnimationNodeBlendTree。
animation_node_renamed(object_id: int, old_name: String, new_name: String) 🔗
繼承此類且具有內部樹的節點在其動畫節點名稱變更時會發出此訊號。發出者包含 AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine 與 AnimationNodeBlendTree。
tree_changed() 🔗
繼承此類且具有內部樹的節點在其動畫節點內容變更時會發出此訊號。發出者包含 AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine、AnimationNodeBlendTree 與 AnimationNodeTransition。
列舉
enum FilterAction: 🔗
FilterAction FILTER_IGNORE = 0
不使用篩選。
FilterAction FILTER_PASS = 1
符合篩選器的路徑將被允許通過。
FilterAction FILTER_STOP = 2
符合篩選器的路徑將被捨棄。
FilterAction FILTER_BLEND = 3
符合篩選器的路徑將依混合值進行混合。
屬性說明
若為 true,啟用篩選功能。
方法說明
String _get_caption() virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法可覆寫動畫節點的顯示標題。
AnimationNode _get_child_by_name(name: StringName) virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法可依 name 取得子動畫節點。
Dictionary _get_child_nodes() virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法以 名稱: 節點 字典順序回傳所有子動畫節點。
Variant _get_parameter_default_value(parameter: StringName) virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法可回傳參數 parameter 的預設值。參數是動畫節點的自訂本地記憶體,可於多棵樹重用。
Array _get_parameter_list() virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法可回傳本節點的屬性清單。參數為動畫節點的自訂本地記憶體,資源可於多棵樹重用。格式類似 Object.get_property_list()。
bool _has_filter() virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法以決定混合樹編輯器是否要在此節點顯示篩選器編輯。
bool _is_parameter_read_only(parameter: StringName) virtual const 🔗
繼承 AnimationRootNode 時,實作此虛方法可判定參數 parameter 是否唯讀。參數是動畫節點的自訂本地記憶體,可於多棵樹重用。
float _process(time: float, seek: bool, is_external_seeking: bool, test_only: bool) virtual 🔗
已棄用: Currently this is mostly useless as there is a lack of many APIs to extend AnimationNode by GDScript. It is planned that a more flexible API using structures will be provided in the future.
繼承 AnimationRootNode 時,實作此虛方法可在處理本動畫節點時執行自訂程式碼。time 為相對增量,除非 seek 為 true,則為絕對值。
可在此呼叫 blend_input()、blend_node() 或 blend_animation()。亦可使用 get_parameter() 與 set_parameter() 來讀寫本地記憶體。
此函式應回傳處理後的 delta。
bool add_input(name: String) 🔗
為動畫節點新增一個輸入。僅對用於 AnimationNodeBlendTree 的節點有用。若新增失敗則回傳 false。
void blend_animation(animation: StringName, time: float, delta: float, seeked: bool, is_external_seeking: bool, blend: float, looped_flag: LoopedFlag = 0) 🔗
依 blend 值混合動畫(名稱必須存在於連結的 AnimationPlayer 中)。可傳入 time、delta,以及是否發生 seeked。
looped_flag 由內部流程於迴圈結束後立即使用。
float blend_input(input_index: int, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) 🔗
混合一個輸入。僅對用於 AnimationNodeBlendTree 的節點有用。time 為相對增量,除非 seek 為 true,此時為絕對值。可選擇傳入篩選模式。
float blend_node(name: StringName, node: AnimationNode, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) 🔗
混合另一個動畫節點(當此節點包含子動畫節點時)。僅在你繼承自 AnimationRootNode 時有意義,否則編輯器無法顯示它以供新增。
int find_input(name: String) const 🔗
回傳與名稱 name 對應的輸入索引;若不存在則回傳 -1。
此動畫節點的輸入數量,僅對用於 AnimationNodeBlendTree 的節點有用。
String get_input_name(input: int) const 🔗
依索引取得輸入名稱。
Variant get_parameter(name: StringName) const 🔗
取得參數值。參數是動畫節點的自訂本地記憶體,可於多棵樹重用。
int get_processing_animation_tree_instance_id() const 🔗
回傳擁有此節點的 AnimationTree 之物件 ID。
注意: 僅應在 AnimationNodeExtension._process_animation_node() 之內呼叫;否則將回傳無效 ID。
bool is_path_filtered(path: NodePath) const 🔗
若指定路徑已被過濾則返回 true。
bool is_process_testing() const 🔗
若此動畫節點正於僅測試模式下被處理,則返回 true。
void remove_input(index: int) 🔗
移除輸入;僅在節點非活動時呼叫。
void set_filter_path(path: NodePath, enable: bool) 🔗
新增或移除篩選器路徑。
bool set_input_name(input: int, name: String) 🔗
設定索引 input 處輸入的名稱;若設定失敗則回傳 false。
void set_parameter(name: StringName, value: Variant) 🔗
設定自訂參數。此參數作為本地記憶體,資源可在多棵樹或多個場景共用。