Help playing animation backwards

Hi everbody, i’m kinda of new to Unity and learning.

I’m trying to make an small FPS, and I want to make my character hide it’s weapon and pull the other weapon whenever i command him to change it.

For this, i have many small animation for pulling out a weapon. The logical thing would be to play this animation backwards to pull in a weapon and the play normally the animation where the player pulls the nwe weapon.

I’m using this succefuly to play an animation backwards, something like this:

hand.animation[“bridge”].speed = -1; hand.animation[“bridge”].time = hand.animation[“bridge”].length; hand.animation.Play(“bridge”);

But I’m getting strange results when trying to reproduce the animation backwards using PlayQueued:

hand.animation[“bridge”].speed = -1; hand.animation[“bridge”].time = hand.animation[“bridge”].length; hand.animation.PlayQueued(“bridge”);

The animation plays backwards properly, but the animation where the player pulls out the new weapon plays backward as well !

Can anyone explain me what’s wrong ? and how to play an animation backwards using PlayQueued?, Im not supossed to do it like this ?, thanks !

Just a thought, I’ve never tried to play an animation backwards in unity, but if you duplicate the animation within unity you can call the two animations from separate names. You can do this by going into the prefab, finding the desired animation and simply cmd + D ( ctrl + D if windows ). Rename it.

For a scripting solution, see who else replies :slight_smile:

Did you make sure to set the new animations speed to 1 before playing it?

Yes, I’m setting the speed back to 1 when playing the next animation.

There seems to be an bug in unity that won’t allow animations that are being played from PlayQueued from changing speed. I’ve done a couple of tests and it seems to not work at all.

Gonna use a new backward animation then.

Thanks for the help !

Whenever I need a backwards version of one of my anims, I duplicate the clip in script and edit the speed of the new clip, like this:

function Start ()
{
	animation.AddClip(animation["walk"].clip, "walk_reverse");
	animation["walk_reverse"].speed = -1.0;
}

then just play “walk_reverse” whenever you want to use the backwards clip.

Hey legend411!

Just found this. Couldn’t get reverse to work. Tried your suggestion works perfectly :slight_smile:
I assume some kind of bug in Unity…

Thanks!!

:slight_smile:

Thanks gonna try this out >> i was trying to play my animation backward last night with just .speed = -1.0 and the animation didn’t work it just was frozen or stuck at the end part of the animation and didn’t play the rest of the animation > so im gonna try legend411’s idea > it must be a bug

Thanks legend ! now i got my animation playing backward finally. … but now i gotta fix this other animation that plays sideways… any ideas on how to fix it ? i tried reimporting with moving the pivot and it is the same … im using 3dsmax