AnimationNodeStateMachine
A state machine with multiple AnimationRootNode
s, used by AnimationTree
.
class AnimationNodeStateMachine
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.
Example:
Superclasses
class AnimationRootNode
Base class for
AnimationNode
s that hold one or multiple composite animations. Usually used fortreeRoot
.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
Instance members
var allowTransitionToSelf: Bool
If
true
, allows teleport to the self state withtravel(toNode:resetOnTeleport:)
. When the reset option is enabled intravel(toNode:resetOnTeleport:)
, the animation is restarted. Iffalse
, nothing happens on the teleportation to the self state.var resetEnds: Bool
If
true
, treat the cross-fade to the start and end nodes as a blend with the RESET animation.var stateMachineType: AnimationNodeStateMachine.StateMachineType
This property can define the process of transitions for different use cases. See also
AnimationNodeStateMachine.StateMachineType
.func addNode(name: StringName, node: AnimationNode?, position: Vector2
) Adds a new animation node to the graph. The
position
is used for display in the editor.func addTransition(from: StringName, to: StringName, transition: AnimationNodeStateMachineTransition?
) Adds a transition between the given animation nodes.
func getGraphOffset(
) -> Vector2 Returns the draw offset of the graph. Used for display in the editor.
func getNode(name: StringName
) -> AnimationNode? Returns the animation node with the given name.
func getNodeName(node: AnimationNode?
) -> StringName Returns the given animation node’s name.
func getNodePosition(name: StringName
) -> Vector2 Returns the given animation node’s coordinates. Used for display in the editor.
func getTransition(idx: Int32
) -> AnimationNodeStateMachineTransition? Returns the given transition.
func getTransitionCount(
) -> Int32 Returns the number of connections in the graph.
func getTransitionFrom(idx: Int32
) -> StringName Returns the given transition’s start node.
func getTransitionTo(idx: Int32
) -> StringName Returns the given transition’s end node.
func hasNode(name: StringName
) -> Bool Returns
true
if the graph contains the given animation node.func hasTransition(from: StringName, to: StringName
) -> Bool Returns
true
if there is a transition between the given animation nodes.func removeNode(name: StringName
) Deletes the given animation node from the graph.
func removeTransition(from: StringName, to: StringName
) Deletes the transition between the two specified animation nodes.
func removeTransitionByIndex(idx: Int32
) Deletes the given transition by index.
func renameNode(name: StringName, newName: StringName
) Renames the given animation node.
func replaceNode(name: StringName, node: AnimationNode?
) Replaces the given animation node with a new animation node.
func setGraphOffset(Vector2
) Sets the draw offset of the graph. Used for display in the editor.
func setNodePosition(name: StringName, position: Vector2
) Sets the animation node’s coordinates. Used for display in the editor.