Closed nstryder closed 2 years ago
Hello, it seems that if you interrupt a currently playing animation with another play() call, it seems to use the current values as the new initial value, and then animate from there, instead of resetting first, and then playing the animation.
Yes, this is correct and was the intended behaviour for Anima.
In your case, you can move the anima initialisation in the _ready
function, as play
will use the value of when the animation is created as initial one:
func _ready():
var anima = Anima.begin(self)
anima.then({ node = self, animation = "wobble", duration = 0.2 })
func _input():
if Input.is_action_just_pressed("use_ability"):
anima.play()
Said that I will add a reset
function that will reset the node to its initial values, so a subsequent play
will behave as you expect.
I checked the live demo for anima and it doesn't seem to have this problem. On checking the code, you seem to avoid this by duplicating the original node then hiding it. That seem like a janky solution for me though.
I assume you're talking about the demo that showcases the animations. Yes, in that case, the duplication was needed because the animation is created when you choose animation and it uses wherever value the node has at the moment of the preview. However, this will change with the next version of Anima as you'll be able to specify custom initial values.
Oh, that makes sense! I'll close out this issue then, as I guess this was more of me not understanding the docs correctly. Thank you!
Cool, I'll use the feedback to improve the documentation :)
Hello, it seems that if you interrupt a currently playing animation with another
play()
call, it seems to use the current values as the new initial value, and then animate from there, instead of resetting first, and then playing the animation.I could be missing a step though; I'm just following what I saw in the docs:
The animation basically plays everytime I hit a key. Attached is a video of what it looks like. As you can see, it starts to veer way off its original position.
https://user-images.githubusercontent.com/45138063/153941734-7b249a69-903e-441e-8ccb-134a71d31c3d.mp4
I checked the live demo for anima and it doesn't seem to have this problem. On checking the code, you seem to avoid this by duplicating the original node then hiding it. That seem like a janky solution for me though.
My current workaround is to toggle the control's visibility off then on. This only works for nodes in a container though, since the container can reset its children's position/rotation/scale. Still, I was wondering if there's something I'm missing so I don't have to even resort to a workaround?
Note: I'm using Anima 0.3.1