Question by
KnobAtCoding · Mar 02, 2016 at 01:11 PM ·
c#animation
Animation Looping Incorrectly
Hello. Every time I hold down the up key, the animation plays one frame, and gets stuck and keeps playing one frame of the animation. I'm guessing it's because GetKey returns every update. But what could I do differently to get past the bug and still have my character work?
void Update () {
if (Input.GetKey("right"))
{
transform.Rotate(0, 30 * speed * Time.deltaTime, 0);
}
if (Input.GetKey("up"))
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
anim.Play("Walk", -1, 0f);
}
if (Input.GetKey("down"))
{
transform.Translate(Vector3.back * speed * Time.deltaTime);
}
Comment