poohcom1 / godot-animated-sprite-2-player

A Godot addon to convert animated sprite frames to animations in an animation player.
https://godotengine.org/asset-library/asset/1605
MIT License
51 stars 4 forks source link

2 bugs #12

Open Kylemcarthur opened 4 months ago

Kylemcarthur commented 4 months ago

Hey there! Thanks for this plugin, it's an awesome improvement over Godot's pretty clunky animation workflow.

I discovered 2 bugs this week in my project. One of them I believe I was able to solve with a simple code change in the plugin, and the other I was able to fix in my project, but I have absolutely no clue what caused it.

  1. Changing the value of Sprite.frame at the same time as Sprite.animation key is not being updated correctly when the animation track is below the frame track (pictured). image Place the animation track above the frame track fixes this issue (pictured). image From testing, it appears that the AnimationPlayer always plays the first frame (and no others) that is used in the AnimatedSprite2D node animation. This will not update in game until the animation key is reached on the animation track, where frames after this point will update correctly. I assume that the engine reads the tracks top-down, so any sprite frames that appear directly "up or left" of the animation key are treated as having no value and are skipped entirely. You can easily test this by importing an animation, then change the value of Sprite.frame at time 0 to anything else, and you can see that this frame will be ignored in favor of the first frame from the AnimatedSprite2D. If you move the Sprite.animation key further along the timeline, this will become true for all frames above or before it. However, if the animation plays again (queue or loop), it will be updated despite this, presumably because the "animation" value was already set by the previous play of it. If the animation changes to something else first, this will break again.

I fixed this pretty simply by just reversing the order that the plugin adds the tracks by default.

anim_track = animation.add_track(Animation.TYPE_VALUE, 0)
frame_track = animation.add_track(Animation.TYPE_VALUE, 1)
  1. I had a very strange bug of an animation that was somehow constantly queueing itself to be played again (specifically queuing, not looping) infinitely. image

How this happened, I have no idea, and I wasn't able to replicate the cause. However, when opening up the animation library in the scene for it, I found the line that I assume was causing that to happen. image Looking over the plugins code, I wasn't able to find anything that could cause this to happen, but I don't understand it well enough to rule it out since it's the only plugin I'm using.

This was fixed by changing the name of the animation in the AnimationPlayer, saving, reloading the project, then changing the animation name back to what it was originally. I don't have a code fix for this to prevent it from occurring again.

poohcom1 commented 4 months ago

Bug 2 is very odd indeed. As you've said, the plugin itself has no reference to AnimationPlayer.queue, so I don't see how it could cause the queue issue. Since it's not reproducible there's not much I can do, but if you're able to reproduce it you can report more details here.

As for the first issue if the solutions works for you, you can open up a PR and I'll be happy to merge it.