Changing animations without resetting frames?

Hello I have an object with 2 animations that are the same but a different colour. Animation “idle” has 3 frames and so does animation “hit” how do I sync both animations when changing from one animation to the other without resetting the loop each time?

This is what I want to do

When “cross” is in collision with “eye” and “idle” animation is frame 1 then change the animation to “hit” frame 2 for 0.1 sec then back to “idle” frame 3 and if “idle” is frame 2 change animation to “hit” frame 3 then back to “idle” frame 1 and so on for each frame.



Before you set the animation, get the current idle animation frame and store it in a variable. After you set the hit animation, change the animation frame to the one what you stored in the variable.

Similarly for changing from hit to idle animations.

you can add sub event below
even : the animation of eye is “idle”
sub even : the animation frame of eye = 0 (first frame of the animation)

and the action is:
action :
set animation of eye to “hit”
change the animation frame of eye set to 1 (second frame of the animation)
pause the animation of eye

Thanks how do I get the current frame of an animation what is the condition?

It’s in the actions. You can’t assign values to variables in the conditions. Use eye.sprite() to get the frame number (yeah, I know, it’s not very obvious).

Having allot of trouble with this. How do I declare the animation name and frame number in a variable?

I found two expressions objectname.Animation() (animation) and objectname.Sprite() (frame) but I have no idea how to use them?

So, set the variable to objectname.Sprite(). When you set the frame of the next animation, use the value in the variable.

1 Like

Thanks solved here Sprite flash solid white when damaged