I don’t understand why, but for one of my scenes, (It’s a boss fight), Whenever I start the take hit animation, the animation just keeps playing, like as if it was in a loop. I checked my code many times, and I only call the take hit animation once, there is nothing in my code that is telling it to repeat whatsoever! Is this a bug with Godot, because I am out of ideas on what to do right now.
The animation does not loop. It says mode 0 which means not looping.
The following is console output, I print out the details from animation player signals, and I specifically printed out all of the times I called animation_player.play(take_hit) To make sure this wasnt me replaying the same animation
take hit animation loop mode: 0
Playing take hit animation...
Started animation: hit
Finished animation: hit
Started animation: hit
Finished animation: hit
Started animation: hit
Finished animation: hit
Started animation: hit
...
Where do you store these animation names that you recall here?
take_hit_animation
idle_animation
fight_idle_animation
... etc.
Can you check if maybe these aren’t being set to “hit” by accident?
You can also put a breakpoint in your _animation_finished() function and track down the exact path what happens after the hit animation is finished and how it happens to restart itself.
also I would try to leverage Animation Trees in Godot as they can clean up your codebase and reduce the amount of signals needed to just everything into a node!
Also while debugging don’t be afraid to add print statements everywhere. this will help know exactly where the code is going, if you don’t want to use breakpoints
The animations are stored within the node itself. All animation code for the entity is executed in the code I have given here. I could track down the cause like you said, However it was very surprising to me because I don’t call hit animation anywhere but here.
Yes, but this snippet doesn’t have the variables, which store the animation names. But nonetheless, even though you set it in code, it could be accidentally changed at runtime, so I suggest you stepping into the code with breakpoints to see the current state.