- Home /
Question by
APenguin · Feb 20, 2014 at 05:17 PM ·
c#animation script
Reverse animation c# does not work.
if (Input.GetKey ("w"))
{
animation["walk"].speed=2.0f;
animation.CrossFade ("walk");
transform.Translate (0, 0, translation * Time.deltaTime);
} else if (Input.GetKey ("s"))
{
//animation["run"].wrapMode = WrapMode.Once;
animation["walk"].speed=-1;
animation["walk"].time = animation["walk"].length;
animation.Play("walk");
//transform.Translate(0,0, -translation * Time.deltaTime);
} else {
animation.CrossFade ("idle");
}
That is my code so far. I want my walking animation to reverse when the s key is pressed. However what happens is the animation freezes when i press the s key. When i press w it works fine. Any reason to why this doesn't work?
Comment
fixed it. I had to take away the animation["time"].time.
Your answer
![](https://koobas.hobune.stream/wayback/20220613134145im_/https://answers.unity.com/themes/thub/images/avi.jpg)