#Animations not playing properly when using AnimationTree

1 messages · Page 1 of 1 (latest)

tropic beacon
#

So I have 2 animations, idle, and attack.

I set up an AnimationTree using the root: AnimationNodeBlendTree and have a picture of it attached.

I want to play the attack animation when the attacking transition state is set to true, and I'm setting it via code as follows:

    animation_tree.set("parameters/attacking/transition_request", true)```

All of this is working just fine seemingly.

The issue is, that when the attack animation plays, the arms of my character don't move from their idle position.

I have a suspicion that it has to do with maybe the fact that both idle and attack are altering the rotation of the arms (none of the other parts are being set by both animations), but I don't know, and there's gotta be a way around this I would think.

Also, if I manually change the transition in the tree, the animations work fine which is weird.

I'm only having the issue when the game is running. Any ideas?
signal whale
#

did you try passing the parameter as a string: "true"

solid ridge
#

true nad false in your case are not booleans. U just named them that way. They are states of something like an enum.

tropic beacon
#

Ahhh, that makes sense, thanks, but it's still having the same behavior

#

The remote scene is also showing the states changing as expected, but the animations are just not right (again, only when in play mode)

#

After attacking and going back to idle, the head turn from the attack doesn't reset

#

and the arms don't swing during the attack, instead doing their idle animation

solid ridge
#

Pls show your entire scene setup.

tropic beacon
#

Sure, what part the hierarchy? Animation Tree settings?

solid ridge
tropic beacon
#

Yeah, using this line: ``` get_tree().create_timer(0.4).timeout.connect(set_idle)

func set_idle():

animation_tree.set("parameters/attacking/transition_request", "false")```

#

which runs after the attack

#

But when it transitions back, it keeps certain motions from the attack animation, like the head rotation

#

It's like body parts that are used in both animations are getting overriden or something along those lines

solid ridge
#

In Blender or in Godot select all bone and set a keyframe at the beginning. That goes for every animation.

tropic beacon
#

Not every bone, no, but in fact, it's the bones that they both keyframe at the beginning that are not animating properly between them.

#

So like the Arm rotation has a keyframe in both animations at the beginning

tropic beacon
#

and that's the one not working 😓

#

And again, it works in the scene of the character, if I manually switch the state of the animation tree

#

It's only when I run the game that it doesn't work 🤔

tropic beacon
#

Yeah... I tried scaling the arm during the attack animation, and that worked, since I'm not scaling the arm during the idle animation.

#

But for some reason, rotation of the arm (used in both animations) is just not working. It just stays in whatever state it starts in

#

Also, maybe it's worth mentioning that my other character who is not using an AnimationTree is working fine

#

I'm trying to learn AnimationTrees and I'm having this issue, so I thought maybe it's some AnimationTree setting I have wrong, but I can't tell what.

solid ridge
#

Everything works fine for me.

tropic beacon
solid ridge
tropic beacon
#

Hmm I wonder if that could be the issue, I honestly don't know 😅

#

I'm just making very simple animations in Godot using the AnimationPlayer and moving/rotating nodes

solid ridge
tropic beacon
#

Yep, including the arms in question haha

#

I removed the AnimationTrees, and if I just use the AnimationPlayer and play the animations directly via code it works.... Not ideal since the point of this was to learn how to use AnimationTrees haha

solid ridge
#

can u make a short video showing and demonstrating it?

Your scene-tree.
Script
AnimationPlayer - showing each animation

Or just give me your project if it is tiny.

tropic beacon
#

Ok gif and screenshot dump incoming:

#

Script:

#

I remade the AnimationTree thinking it might help and made it just like your example, no change

#

scene tree:

#

Showing that the arm has rotation keyframes and is indeed the same arm object in both animations (I thought maybe I had the wrong object 😅 )

#

Animations in scene view:

#

Animation when project is running:

#

The only thing moving is the leg (which is not touched by the idle animation and has no keyframes there, but does have a RESET track)

#

Not sure if this is helpful, but I also noticed that after attacking, the leg is not resetting to the idle position, this could be since the leg has no keyframes in the idle animation but yeah

#

Hmm adding a Xfade time and curve fixed the leg resetting actually. So maybe that's unrelated

#

Oh wow I think maybe I got it working!

#

So, I was just using the AnimationPlayer before and decided to start using AnimationTree, and my idle animation was set to "Autoplay on Load" in the AnimationPlayer from before.

#

Making it so that the AnimationPlayer has no animation set to "Autoplay on Load" seems to have fixed the issue

solid ridge
#

Well, glad that u fixed it!

tropic beacon
solid ridge