How to play animation backward, by user clicking?

I have to pull something, so if user click again, and pulling animation is playing, how to play it backward?
I tried this
void OnMouseDown(){
animator.speed =-1;
}

But it saying me in console animator’s speed can be negative only in animator’s recorder.
How to achieve this?

You can change the state’s speed multiplier instead.

You’ll need to expose it as a property, as explained in this post:
http://forum.unity3d.com/threads/mecanim-change-animation-speed-of-specific-animation-or-layers.160395/page-2#post-2000306

And the use animator.SetFloat(“myPropertyName”, -1) in your script.

1 Like

There is also a good summary a bit further down thread
http://forum.unity3d.com/threads/mecanim-change-animation-speed-of-specific-animation-or-layers.160395/page-2#post-2544999

It works, thanks.