I have a blender file with two simple animations.
It is a model of a shotgun, with one animation that moves the pump handle backwards and one that moves the bolt backwards.
Just playing one of the animations works fine, I can rack the pump handle by calling play(“animation”) on the automatically created AnimationPlayer, then listen to the animation_finished event and call play_backwards to move the handle back. Great.
Now I want to move the bolt and handle at the same time.
I cannot figure out how to do this.
Suggestions all over the internet say to use AnimationTree but never explain how to actually do that - and yes, I did read the documentation, it isn’t helping. Sure, I can add a tree and create a BlendTree inside that contains the graph that everyone suggests (2x animation → blend2 with 0.5 → output), but all that does is play half of both animations once at scene initialization.
How do I actually get the AnimationTree to play both animations in full, on demand? Is this even possible?
Is AnimationTree just the wrong thing to use here? I did attempt to use multiple AnimationPlayers, as some forum posts suggested, but I can’t figure out how to tell the second player to use the animations from the imported model.
What am I missing here? Just playing two animations at once has to be possible, right?
if you want to play 2 animations at the same time you need 2 animationplayers. you can save the animationlibrary from the first animationplayer as a file and then load that library in the second animationplayer
From the AnimationTree, under its parameters, you may get the playback state and change values on the fly (such transition to states in state machines, change the blend tree values, etc). The docs explain how to use it.
@herrspaten using two AnimationPlayers with the extracted animation works perfectly for this scenario, thank you!
@joelgomes1994
I am still trying to figure out the basics of the AnimationTree. I am not sure whether I am just looking in the wrong place or if there are some implied concepts that I am unaware of.
It looks to me like the AnimationTree assumes that animation is always happening. Is that correct?
If that is correct and I want to animate an object that is static most of the time I would have to create an idle animation that is just one frame of nothing as a default state, correct?
There does not appear to be a concept of directly triggering an animation - beyond the one-shot node, which requires another animation to already be happening.
Is the basic idea here that you do not directly trigger / control animations and instead create conditions under which animations happen?
It feels like I am missing some sort of vital bit of connecting information for all of this to start making sense.
Yes, it assumes the animation is always happening.
Maybe you could use a state machine node (maybe as the root node) where the default animation is a RESET animation (the default transform animation in Godot), then it can transition to a blend tree where you can mix both animations (Add, if I remember correctly). Then when it finishes it can switch back to the RESET animation state.