AnimationNodeStateMachine

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

A state machine with multiple AnimationRootNode s, used by AnimationTree.

描述

Contains multiple AnimationRootNode s representing animation states, connected in a graph. State transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the AnimationNodeStateMachinePlayback object from the AnimationTree node to control it programmatically.


    var state_machine = $AnimationTree.get("parameters/playback")
    state_machine.travel("some_state")

    var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
    stateMachine.Travel("some_state");

属性

方法


枚举

enum StateMachineType:

StateMachineType STATE_MACHINE_TYPE_ROOT = 0

Seeking to the beginning is treated as playing from the start state. Transition to the end state is treated as exiting the state machine.

StateMachineType STATE_MACHINE_TYPE_NESTED = 1

Seeking to the beginning is treated as seeking to the beginning of the animation in the current state. Transition to the end state, or the absence of transitions in each state, is treated as exiting the state machine.

StateMachineType STATE_MACHINE_TYPE_GROUPED = 2

This is a grouped state machine that can be controlled from a parent state machine. It does not work independently. There must be a state machine with state_machine_type of STATE_MACHINE_TYPE_ROOT or STATE_MACHINE_TYPE_NESTED in the parent or ancestor.


属性说明

bool allow_transition_to_self = false

  • void set_allow_transition_to_self ( value: bool )
  • bool is_allow_transition_to_self ( )

If true, allows teleport to the self state with AnimationNodeStateMachinePlayback.travel. When the reset option is enabled in AnimationNodeStateMachinePlayback.travel, the animation is restarted. If false, nothing happens on the teleportation to the self state.


bool reset_ends = false

  • void set_reset_ends ( value: bool )
  • bool are_ends_reset ( )

If true, treat the cross-fade to the start and end nodes as a blend with the RESET animation.

In most cases, when additional cross-fades are performed in the parent AnimationNode of the state machine, setting this property to false and matching the cross-fade time of the parent AnimationNode and the state machine's start node and end node gives good results.


StateMachineType state_machine_type = 0

This property can define the process of transitions for different use cases. See also StateMachineType.


方法说明

void add_node ( name: StringName, node: AnimationNode, position: Vector2 = Vector2(0, 0) )

Adds a new animation node to the graph. The position is used for display in the editor.


void add_transition ( from: StringName, to: StringName, transition: AnimationNodeStateMachineTransition )

Adds a transition between the given animation nodes.


Vector2 get_graph_offset ( ) const1

Returns the draw offset of the graph. Used for display in the editor.


AnimationNode get_node ( name: StringName ) const1

Returns the animation node with the given name.


StringName get_node_name ( node: AnimationNode ) const1

Returns the given animation node's name.


Vector2 get_node_position ( name: StringName ) const1

Returns the given animation node's coordinates. Used for display in the editor.


AnimationNodeStateMachineTransition get_transition ( idx: int ) const1

Returns the given transition.


int get_transition_count ( ) const1

Returns the number of connections in the graph.


StringName get_transition_from ( idx: int ) const1

Returns the given transition's start node.


StringName get_transition_to ( idx: int ) const1

Returns the given transition's end node.


bool has_node ( name: StringName ) const1

Returns true if the graph contains the given animation node.


bool has_transition ( from: StringName, to: StringName ) const1

Returns true if there is a transition between the given animation nodes.


void remove_node ( name: StringName )

Deletes the given animation node from the graph.


void remove_transition ( from: StringName, to: StringName )

Deletes the transition between the two specified animation nodes.


void remove_transition_by_index ( idx: int )

Deletes the given transition by index.


void rename_node ( name: StringName, new_name: StringName )

Renames the given animation node.


void replace_node ( name: StringName, node: AnimationNode )

Replaces the given animation node with a new animation node.


void set_graph_offset ( offset: Vector2 )

Sets the draw offset of the graph. Used for display in the editor.


void set_node_position ( name: StringName, position: Vector2 )

Sets the animation node's coordinates. Used for display in the editor.

2

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

1

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

3

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

4

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

5

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

6

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

7

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

8

无返回值。