AnimationNodeStateMachine

package
v0.0.0-...-fe0704e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Contains multiple AnimationRootNodes 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.

package main

import (
	"graphics.gd/classdb/AnimationNodeStateMachinePlayback"
	"graphics.gd/classdb/AnimationTree"
	"graphics.gd/variant/Object"
)

func ExampleAnimationNodeStateMachine(tree AnimationTree.Instance) {
	var stateMachine = Object.Get(tree, "parameters/playback").(AnimationNodeStateMachinePlayback.Instance)
	stateMachine.Travel("some_state")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsAnimationNodeStateMachine() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsAnimationNode

func (self *Extension[T]) AsAnimationNode() AnimationNode.Instance

func (*Extension[T]) AsAnimationNodeStateMachine

func (self *Extension[T]) AsAnimationNodeStateMachine() Instance

func (*Extension[T]) AsAnimationRootNode

func (self *Extension[T]) AsAnimationRootNode() AnimationRootNode.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddNode

func (self Instance) AddNode(name string, node AnimationNode.Instance)

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

func (Instance) AddTransition

func (self Instance) AddTransition(from string, to string, transition AnimationNodeStateMachineTransition.Instance)

Adds a transition between the given animation nodes.

func (Instance) AllowTransitionToSelf

func (self Instance) AllowTransitionToSelf() bool

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.

func (Instance) AsAnimationNode

func (self Instance) AsAnimationNode() AnimationNode.Instance

func (Instance) AsAnimationNodeStateMachine

func (self Instance) AsAnimationNodeStateMachine() Instance

func (Instance) AsAnimationRootNode

func (self Instance) AsAnimationRootNode() AnimationRootNode.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) GetGraphOffset

func (self Instance) GetGraphOffset() Vector2.XY

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

func (Instance) GetNode

func (self Instance) GetNode(name string) AnimationNode.Instance

Returns the animation node with the given name.

func (Instance) GetNodeList

func (self Instance) GetNodeList() []string

Returns a list containing the names of all animation nodes in this state machine.

func (Instance) GetNodeName

func (self Instance) GetNodeName(node AnimationNode.Instance) string

Returns the given animation node's name.

func (Instance) GetNodePosition

func (self Instance) GetNodePosition(name string) Vector2.XY

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

func (Instance) GetTransition

func (self Instance) GetTransition(idx int) AnimationNodeStateMachineTransition.Instance

Returns the given transition.

func (Instance) GetTransitionCount

func (self Instance) GetTransitionCount() int

Returns the number of connections in the graph.

func (Instance) GetTransitionFrom

func (self Instance) GetTransitionFrom(idx int) string

Returns the given transition's start node.

func (Instance) GetTransitionTo

func (self Instance) GetTransitionTo(idx int) string

Returns the given transition's end node.

func (Instance) HasNode

func (self Instance) HasNode(name string) bool

Returns true if the graph contains the given animation node.

func (Instance) HasTransition

func (self Instance) HasTransition(from string, to string) bool

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

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) RemoveNode

func (self Instance) RemoveNode(name string)

Deletes the given animation node from the graph.

func (Instance) RemoveTransition

func (self Instance) RemoveTransition(from string, to string)

Deletes the transition between the two specified animation nodes.

func (Instance) RemoveTransitionByIndex

func (self Instance) RemoveTransitionByIndex(idx int)

Deletes the given transition by index.

func (Instance) RenameNode

func (self Instance) RenameNode(name string, new_name string)

Renames the given animation node.

func (Instance) ReplaceNode

func (self Instance) ReplaceNode(name string, node AnimationNode.Instance)

Replaces the given animation node with a new animation node.

func (Instance) ResetEnds

func (self Instance) ResetEnds() bool

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.

func (Instance) SetAllowTransitionToSelf

func (self Instance) SetAllowTransitionToSelf(value bool)

SetAllowTransitionToSelf sets the property returned by [IsAllowTransitionToSelf].

func (Instance) SetGraphOffset

func (self Instance) SetGraphOffset(offset Vector2.XY)

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

func (Instance) SetNodePosition

func (self Instance) SetNodePosition(name string, position Vector2.XY)

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

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetResetEnds

func (self Instance) SetResetEnds(value bool)

SetResetEnds sets the property returned by [AreEndsReset].

func (Instance) SetStateMachineType

func (self Instance) SetStateMachineType(value StateMachineType)

SetStateMachineType sets the property returned by [GetStateMachineType].

func (Instance) StateMachineType

func (self Instance) StateMachineType() StateMachineType

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

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type MoreArgs

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) AddNode

func (self MoreArgs) AddNode(name string, node AnimationNode.Instance, position Vector2.XY)

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

type StateMachineType

type StateMachineType int //gd:AnimationNodeStateMachine.StateMachineType
const (
	// Seeking to the beginning is treated as playing from the start state. Transition to the end state is treated as exiting the state machine.
	StateMachineTypeRoot StateMachineType = 0
	// 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.
	StateMachineTypeNested StateMachineType = 1
	// 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 [StateMachineType] of [StateMachineTypeRoot] or [StateMachineTypeNested] in the parent or ancestor.
	//
	// [StateMachineType]: https://pkg.go.dev/graphics.gd/classdb/#Instance.StateMachineType
	StateMachineTypeGrouped StateMachineType = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL