Interrupt and replay an animation from the beginning AnimationTree graph

Godot Version

Godot 4.2.1

Question

Hi,

In an AnimationTree, if you need to replay a one-shot animation state without transitioning through an intermediate state—such as an attack animation interrupted by a second attack with the same animation state in the tree—how would you achieve this?

I haven’t found any straightforward methods without resorting to unconventional hacks, which makes me wonder if I’m approaching this the wrong way.

Here’s my current simple AnimationTree:

image

Thanks !

You can always start a node inside an AnimationNodeStateMachine by getting the AnimationNodeStateMachinePlayback and calling AnimationNodeStateMachinePlayback.start() even if that node isn’t connected with anything.

Example:

func die() -> void:
	var playback = animation_tree.get("parameters/locomotion/playback") # "locomotion" is my AnimationNodeStateMachine
	playback.start('death')

Works great! Since my animation tree had the animation AnimationNodeStateMachine directly, I just had to change the path to:

var playback = animtree.get("parameters/playback")

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.