Animation Player that uses a node graph for blending Animations.
    public class AnimationTreePlayer : Node

A node graph tool for blending multiple animations bound to an AnimationPlayer. Especially useful for animating characters or other skeleton-based rigs. It can combine several animations to form a desired pose.

It takes Animations from an AnimationPlayer node and mixes them depending on the graph.

Inheritance Chain

Constructors

    public AnimationTreePlayer()

Properties

    public bool Active { get; set; }

If true, the AnimationTreePlayer is able to play animations. Default value: false.

    public NodePath BasePath { get; set; }

The node from which to relatively access other nodes. Default value: "..".

It accesses the Bones, so it should point to the same Node the AnimationPlayer would point its Root Node at.

    public NodePath MasterPlayer { get; set; }

The path to the AnimationPlayer from which this AnimationTreePlayer binds animations to animation nodes.

Once set, Animation nodes can be added to the AnimationTreePlayer.

    public AnimationProcessMode PlaybackProcessMode { get; set; }

The thread in which to update animations. Default value: ANIMATION_PROCESS_IDLE.

Methods

    public void AddNode(NodeType type, string id)

Adds a type node to the graph with name id.

    public void Advance(float delta)

Shifts position in the animation timeline. Delta is the time in seconds to shift.

    public Animation AnimationNodeGetAnimation(string id)

Returns the AnimationPlayer’s Animation bound to the AnimationTreePlayer’s animation node with name id.

    public string AnimationNodeGetMasterAnimation(string id)

Returns the name of the MasterPlayer’s Animation bound to this animation node.

    public float AnimationNodeGetPosition(string id)

    public void AnimationNodeSetAnimation(string id, Animation animation)

Binds a new Animation from the MasterPlayer to the AnimationTreePlayer’s animation node with name id.

    public void AnimationNodeSetFilterPath(string id, NodePath path, bool enable)

If enable is true, the animation node with ID id turns off the track modifying the property at path. The modified node’s children continue to animate.

    public void AnimationNodeSetMasterAnimation(string id, string source)

Binds the Animation named source from MasterPlayer to the animation node id. Recalculates caches.

    public bool AreNodesConnected(string id, string dstId, int dstInputIdx)

Returns whether node id and dstId are connected at the specified slot.

    public float Blend2NodeGetAmount(string id)

Returns the blend amount of a Blend2 node given its name.

    public void Blend2NodeSetAmount(string id, float blend)

Sets the blend amount of a Blend2 node given its name and value.

A Blend2 Node blends two animations with the amount between 0 and 1.

At 0, Output is input a.

Towards 1, the influence of a gets lessened, the influence of b gets raised.

At 1, Output is input b.

    public void Blend2NodeSetFilterPath(string id, NodePath path, bool enable)

If enable is true, the blend2 node with ID id turns off the track modifying the property at path. The modified node’s children continue to animate.

    public float Blend3NodeGetAmount(string id)

Returns the blend amount of a Blend3 node given its name.

    public void Blend3NodeSetAmount(string id, float blend)

Sets the blend amount of a Blend3 node given its name and value.

A Blend3 Node blends three animations with the amount between -1 and 1.

At -1, Output is input b-.

From -1 to 0, the influence of b- gets lessened, the influence of a gets raised and the influence of b+ is 0.

At 0, Output is input a.

From 0 to 1, the influence of a gets lessened, the influence of b+ gets raised and the influence of b+ is 0.

At 1, Output is input b+.

    public Vector2 Blend4NodeGetAmount(string id)

Returns the blend amount of a Blend4 node given its name.

    public void Blend4NodeSetAmount(string id, Vector2 blend)

Sets the blend amount of a Blend4 node given its name and value.

A Blend4 Node blends two pairs of animations.

The two pairs are blended like blend2 and then added together.

    public Error ConnectNodes(string id, string dstId, int dstInputIdx)

Connects node id to dstId at the specified input slot.

    public void DisconnectNodes(string id, int dstInputIdx)

Disconnects nodes connected to id at the specified input slot.

    public AnimationProcessMode GetAnimationProcessMode()

Getter for PlaybackProcessMode

    public NodePath GetBasePath()

Getter for BasePath

    public NodePath GetMasterPlayer()

Getter for MasterPlayer

    public string[] GetNodeList()

Returns a PoolStringArray containing the name of all nodes.

    public bool IsActive()

Getter for Active

    public float MixNodeGetAmount(string id)

Returns mix amount of a Mix node given its name.

    public void MixNodeSetAmount(string id, float ratio)

Sets mix amount of a Mix node given its name and value.

A Mix node adds input b to input a by a the amount given by ratio.

    public bool NodeExists(string node)

Check if a node exists (by name).

    public int NodeGetInputCount(string id)

Return the input count for a given node. Different types of nodes have different amount of inputs.

    public string NodeGetInputSource(string id, int idx)

Return the input source for a given node input.

    public Vector2 NodeGetPosition(string id)

Returns position of a node in the graph given its name.

    public NodeType NodeGetType(string id)

Get the node type, will return from NODE_* enum.

    public Error NodeRename(string node, string newName)

Rename a node in the graph.

    public void NodeSetPosition(string id, Vector2 screenPosition)

Sets position of a node in the graph given its name and position.

    public float OneshotNodeGetAutorestartDelay(string id)

Returns autostart delay of a OneShot node given its name.

    public float OneshotNodeGetAutorestartRandomDelay(string id)

Returns autostart random delay of a OneShot node given its name.

    public float OneshotNodeGetFadeinTime(string id)

Returns fade in time of a OneShot node given its name.

    public float OneshotNodeGetFadeoutTime(string id)

Returns fade out time of a OneShot node given its name.

    public bool OneshotNodeHasAutorestart(string id)

Returns whether a OneShot node will auto restart given its name.

    public bool OneshotNodeIsActive(string id)

Returns whether a OneShot node is active given its name.

    public void OneshotNodeSetAutorestart(string id, bool enable)

Sets autorestart property of a OneShot node given its name and value.

    public void OneshotNodeSetAutorestartDelay(string id, float delaySec)

Sets autorestart delay of a OneShot node given its name and value in seconds.

    public void OneshotNodeSetAutorestartRandomDelay(string id, float randSec)

Sets autorestart random delay of a OneShot node given its name and value in seconds.

    public void OneshotNodeSetFadeinTime(string id, float timeSec)

Sets fade in time of a OneShot node given its name and value in seconds.

    public void OneshotNodeSetFadeoutTime(string id, float timeSec)

Sets fade out time of a OneShot node given its name and value in seconds.

    public void OneshotNodeSetFilterPath(string id, NodePath path, bool enable)

If enable is true, the oneshot node with ID id turns off the track modifying the property at path. The modified node’s children continue to animate.

    public void OneshotNodeStart(string id)

Starts a OneShot node given its name.

    public void OneshotNodeStop(string id)

Stops the OneShot node with name id.

    public void RecomputeCaches()

Manually recalculates the cache of track information generated from animation nodes. Needed when external sources modify the animation nodes’ state.

    public void RemoveNode(string id)

Removes the animation node with name id.

    public void Reset()

Resets this AnimationTreePlayer.

    public void SetActive(bool enabled)

Setter for Active

    public void SetAnimationProcessMode(AnimationProcessMode mode)

Setter for PlaybackProcessMode

    public void SetBasePath(NodePath path)

Setter for BasePath

    public void SetMasterPlayer(NodePath nodepath)

Setter for MasterPlayer

    public float TimescaleNodeGetScale(string id)

Returns time scale value of the TimeScale node with name id.

    public void TimescaleNodeSetScale(string id, float scale)

Sets the time scale of the TimeScale node with name id to scale.

The timescale node is used to speed Animations up if the scale is above 1 or slow them down if it is below 1.

If applied after a blend or mix, affects all input animations to that blend or mix.

    public void TimeseekNodeSeek(string id, float seconds)

Sets the time seek value of the TimeSeek node with name id to seconds

This functions as a seek in the Animation or the blend or mix of Animations input in it.

    public void TransitionNodeDeleteInput(string id, int inputIdx)

Deletes the input at inputIdx for the transition node with name id.

    public int TransitionNodeGetCurrent(string id)

Returns the index of the currently evaluated input for the transition node with name id.

    public int TransitionNodeGetInputCount(string id)

Returns the number of inputs for the transition node with name id. You can add inputs by rightclicking on the transition node.

    public float TransitionNodeGetXfadeTime(string id)

Returns the cross fade time for the transition node with name id.

    public bool TransitionNodeHasInputAutoAdvance(string id, int inputIdx)

Returns true if the input at inputIdx on transition node with name id is set to automatically advance to the next input upon completion.

    public void TransitionNodeSetCurrent(string id, int inputIdx)

The transition node with name id sets its current input at inputIdx.

    public void TransitionNodeSetInputAutoAdvance(string id, int inputIdx, bool enable)

The transition node with name id advances to its next input automatically when the input at inputIdx completes.

    public void TransitionNodeSetInputCount(string id, int count)

Resizes the number of inputs available for the transition node with name id.

    public void TransitionNodeSetXfadeTime(string id, float timeSec)

The transition node with name id sets its cross fade time to timeSec.

Inner Types

AnimationProcessMode

Name Value Description
Physics 0 Process animation during the physics process. This is especially useful when animating physics bodies.
Idle 1 Process animation during the idle process.

NodeType

Name Value Description
Output 0 Output node.
Animation 1 Animation node.
Oneshot 2 OneShot node.
Mix 3 Mix node.
Blend2 4 Blend2 node.
Blend3 5 Blend3 node.
Blend4 6 Blend4 node.
Timescale 7 TimeScale node.
Timeseek 8 TimeSeek node.
Transition 9 Transition node.
Tags: