Closed caryd closed 1 year ago
I cannot reproduce this. I have built up a scene where call the AnimationPlayer
manually with play
and in another mode use the animation player state nodes (which internally also just call play
). In my tests the animation state gets reset in both cases which is what I would expect.
https://github.com/derkork/godot-statecharts/assets/327257/eaa14f89-7489-443f-abde-a0f1662a9dac
Could you maybe attach a minimal project that reproduces the issue?
Sure thing. I think I made it as simple as possible. Load it and play the scene.
If you right-click, the sprite will retain the current rotation and go back to 0 rotation. This uses the $StateChart.send_event
If you reload and left-click. The sprite will immediately turn to 0 rotation. This uses the $AnimationPlayer.play
I am still relatively new to Godot, but this seems like it should be doing the same thing. It works flawlessly when there aren't any track alterations.
It would seem that your setup is a bit different from mine, you use an AnimationTree
on top of an AnimationPlayer
and an AnimationTreeState
instead of an AnimationPlayerState
and they work a bit differently. So to actually have comparable results you would need to call on right-click:
$AnimationTree.get("parameters/playback").travel("two")
instead of
$AnimationPlayer.play("two")
And if you do this, you will actually get the exact same results for left and right-click. When you use an AnimationTree
the AnimationTree
is solely responsible for controlling the AnimationPlayer
and you should not use the AnimationPlayer
's play
function at all. From the docs:
When linked with an AnimationPlayer, several properties and methods of the corresponding AnimationPlayer will not function as expected. Playback and transitions should be handled using only the AnimationTree and its constituent AnimationNode(s). The AnimationPlayer node should be used solely for adding, deleting, and editing animations.
If you want to blend the rotate animation with different sprite animations have a look at animation blending (https://docs.godotengine.org/en/stable/tutorials/animation/animation_tree.html). It's sort of fiddely to set up and in my experience requires a lot of trial and error but then again I am by no means an expert on the subject.
In any case I think we can close this as this has more to do with the overall animation setup and is no issue of the state charts library. Please reopen it if you disagree.
Thank you very much for taking the time to explain those differences. I really love this module. Please let me know if I can do anything to help while I use it. Have a great day.
If you have a value set in one animation, like rotation, it gets reset back to 0 when the state changes to another animation.
If you use the normal $AnimationPlayer.play("whatever"), this does not happen.