ANOYONE HELP?

hi guys, this is my first post so yea, here is my little problem, ive got a simple gun “aim down sights” animation and it works perfect playing when i press z down, but i want it to play in reverse with the key z up (so holding down z will make you zoom in, let it go and zoom out. here is my script im sure it would work. no errors btw.
p.s sorry if i was suppose to attach the file

var ZoomSpeed = 1.0;

function LateUpdate ()
{
// Make all animations in this character play at specified speed
for (var state : AnimationState in animation)

{
state.speed = ZoomSpeed;
}

if (Input.GetKeyDown (“z”))
{
animation.Play (“zoomscope”);
}

if (Input.GetKeyUp (“z”))
{
animation[“zoomscope”].speed = -1.0;
}
}

Try this (no guarantee of success) : Unity - Scripting API: Animation.Rewind

yea that didnt work…for me anyway.

Well by the code provided I see two things that may go wrong.

  • after changing the speed of the animation to “-1.0” you haven’t played it
  • on keyDown you should set the animation speed back to “1.0”