play AnimationTree animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pillme

i have added 2 animations from an AnimationPlayer and bledned them. the blend is connected to the output. all very basic stuff. the animation plays correctly and both animations are playing together.

however, how can i start this animation in the game?

something like: self.get_node(“AnimationTree”).play_whatever_animation_i_want()

online i can only find examples using states, but i do not have any.

:bust_in_silhouette: Reply From: spaceyjase

The docs got you covered, I believe you want to blend between them: Using AnimationTree — Godot Engine (stable) documentation in English

anim_tree.set("parameters/eye_blend/blend_amount", 1.0)
# Simpler alternative form:
anim_tree["parameters/eye_blend/blend_amount"] = 1.0

And if not, it has to be covered here: Using AnimationTree — Godot Engine (stable) documentation in English)

i already set the parameter using the nodes editor. what i want is to play the animation.

pillme | 2023-02-24 17:52

i have read the docs, but they only cover how the parameters can be set via code. not that this is a bad thing, but they do not explain how to play the animation.

if the AnimationTree is not used for that, please let me know.

pillme | 2023-02-24 17:56

Ideally, grab the state machine and call the appropriate method; see the docs for the object type. The docs link to an example containing examples of each.

spaceyjase | 2023-02-24 18:15