Make Slime Animation

First I have 8 sprites of slime going from normal state to squeezed state (“O” ->“o”).
It’s controlled by player not AI.
So when I hold left click it need to start animation (“O” ->“o”) then back(“o”->“O”)
and then repeat that while not left click is released.
Than if left click is released it’s need to go back in “O” state ,but not depending at what state is now
So if its going 1(“O”) 2,3,4,5(“o”) at frames
If its at 3rd frame and going at frame 3->4->5 it need to change from squeezing state to expanding.
(not 3->4,but 3->2->1(“O”) then enter at idle animation(can be one sprite)
I tried that with Animator Controller and only with my scripts but I fail ever time.

Too hard for you?

On button release - reverse animation.

I’m not a coder - but that is what you want - reverse the animation when the button is released.

You can use Vector.Lerp to scale the transform.localScale of the slime animation. OnMouse click, assign the transform to a temporary vector2 which you would use to lerp the original transform from, to. then assign the original transform to the temporary transform.

void ShrinkSize ()
    {
        Vector2 scale = transform.localScale; //this is the temporary vector2
        scale = Vector2.Lerp (scale, Vector2.zero, 1f * Time.deltaTime); //lerp its scale
        transform.localScale = scale;   //assign original scale to temporary scale
    }

this is untested so please reply if it works
if you have any questions about this hesitate not to ask

I make it work as that before I asked,but I want to use animation because its looks more realistic that just scaling