Path: blob/master/doc/classes/AnimationNodeStateMachine.xml
10277 views
<?xml version="1.0" encoding="UTF-8" ?>1<class name="AnimationNodeStateMachine" inherits="AnimationRootNode" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">2<brief_description>3A state machine with multiple [AnimationRootNode]s, used by [AnimationTree].4</brief_description>5<description>6Contains 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.7[codeblocks]8[gdscript]9var state_machine = $AnimationTree.get("parameters/playback")10state_machine.travel("some_state")11[/gdscript]12[csharp]13var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;14stateMachine.Travel("some_state");15[/csharp]16[/codeblocks]17</description>18<tutorials>19<link title="Using AnimationTree">$DOCS_URL/tutorials/animation/animation_tree.html</link>20</tutorials>21<methods>22<method name="add_node">23<return type="void" />24<param index="0" name="name" type="StringName" />25<param index="1" name="node" type="AnimationNode" />26<param index="2" name="position" type="Vector2" default="Vector2(0, 0)" />27<description>28Adds a new animation node to the graph. The [param position] is used for display in the editor.29</description>30</method>31<method name="add_transition">32<return type="void" />33<param index="0" name="from" type="StringName" />34<param index="1" name="to" type="StringName" />35<param index="2" name="transition" type="AnimationNodeStateMachineTransition" />36<description>37Adds a transition between the given animation nodes.38</description>39</method>40<method name="get_graph_offset" qualifiers="const">41<return type="Vector2" />42<description>43Returns the draw offset of the graph. Used for display in the editor.44</description>45</method>46<method name="get_node" qualifiers="const">47<return type="AnimationNode" />48<param index="0" name="name" type="StringName" />49<description>50Returns the animation node with the given name.51</description>52</method>53<method name="get_node_list" qualifiers="const">54<return type="StringName[]" />55<description>56Returns a list containing the names of all animation nodes in this state machine.57</description>58</method>59<method name="get_node_name" qualifiers="const">60<return type="StringName" />61<param index="0" name="node" type="AnimationNode" />62<description>63Returns the given animation node's name.64</description>65</method>66<method name="get_node_position" qualifiers="const">67<return type="Vector2" />68<param index="0" name="name" type="StringName" />69<description>70Returns the given animation node's coordinates. Used for display in the editor.71</description>72</method>73<method name="get_transition" qualifiers="const">74<return type="AnimationNodeStateMachineTransition" />75<param index="0" name="idx" type="int" />76<description>77Returns the given transition.78</description>79</method>80<method name="get_transition_count" qualifiers="const">81<return type="int" />82<description>83Returns the number of connections in the graph.84</description>85</method>86<method name="get_transition_from" qualifiers="const">87<return type="StringName" />88<param index="0" name="idx" type="int" />89<description>90Returns the given transition's start node.91</description>92</method>93<method name="get_transition_to" qualifiers="const">94<return type="StringName" />95<param index="0" name="idx" type="int" />96<description>97Returns the given transition's end node.98</description>99</method>100<method name="has_node" qualifiers="const">101<return type="bool" />102<param index="0" name="name" type="StringName" />103<description>104Returns [code]true[/code] if the graph contains the given animation node.105</description>106</method>107<method name="has_transition" qualifiers="const">108<return type="bool" />109<param index="0" name="from" type="StringName" />110<param index="1" name="to" type="StringName" />111<description>112Returns [code]true[/code] if there is a transition between the given animation nodes.113</description>114</method>115<method name="remove_node">116<return type="void" />117<param index="0" name="name" type="StringName" />118<description>119Deletes the given animation node from the graph.120</description>121</method>122<method name="remove_transition">123<return type="void" />124<param index="0" name="from" type="StringName" />125<param index="1" name="to" type="StringName" />126<description>127Deletes the transition between the two specified animation nodes.128</description>129</method>130<method name="remove_transition_by_index">131<return type="void" />132<param index="0" name="idx" type="int" />133<description>134Deletes the given transition by index.135</description>136</method>137<method name="rename_node">138<return type="void" />139<param index="0" name="name" type="StringName" />140<param index="1" name="new_name" type="StringName" />141<description>142Renames the given animation node.143</description>144</method>145<method name="replace_node">146<return type="void" />147<param index="0" name="name" type="StringName" />148<param index="1" name="node" type="AnimationNode" />149<description>150Replaces the given animation node with a new animation node.151</description>152</method>153<method name="set_graph_offset">154<return type="void" />155<param index="0" name="offset" type="Vector2" />156<description>157Sets the draw offset of the graph. Used for display in the editor.158</description>159</method>160<method name="set_node_position">161<return type="void" />162<param index="0" name="name" type="StringName" />163<param index="1" name="position" type="Vector2" />164<description>165Sets the animation node's coordinates. Used for display in the editor.166</description>167</method>168</methods>169<members>170<member name="allow_transition_to_self" type="bool" setter="set_allow_transition_to_self" getter="is_allow_transition_to_self" default="false">171If [code]true[/code], allows teleport to the self state with [method AnimationNodeStateMachinePlayback.travel]. When the reset option is enabled in [method AnimationNodeStateMachinePlayback.travel], the animation is restarted. If [code]false[/code], nothing happens on the teleportation to the self state.172</member>173<member name="reset_ends" type="bool" setter="set_reset_ends" getter="are_ends_reset" default="false">174If [code]true[/code], treat the cross-fade to the start and end nodes as a blend with the RESET animation.175In most cases, when additional cross-fades are performed in the parent [AnimationNode] of the state machine, setting this property to [code]false[/code] and matching the cross-fade time of the parent [AnimationNode] and the state machine's start node and end node gives good results.176</member>177<member name="state_machine_type" type="int" setter="set_state_machine_type" getter="get_state_machine_type" enum="AnimationNodeStateMachine.StateMachineType" default="0">178This property can define the process of transitions for different use cases. See also [enum AnimationNodeStateMachine.StateMachineType].179</member>180</members>181<constants>182<constant name="STATE_MACHINE_TYPE_ROOT" value="0" enum="StateMachineType">183Seeking to the beginning is treated as playing from the start state. Transition to the end state is treated as exiting the state machine.184</constant>185<constant name="STATE_MACHINE_TYPE_NESTED" value="1" enum="StateMachineType">186Seeking 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.187</constant>188<constant name="STATE_MACHINE_TYPE_GROUPED" value="2" enum="StateMachineType">189This 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 [member state_machine_type] of [constant STATE_MACHINE_TYPE_ROOT] or [constant STATE_MACHINE_TYPE_NESTED] in the parent or ancestor.190</constant>191</constants>192</class>193194195