Hello so i have this script and in the void update in doesnt matter wich is first for backwards or run up it always makes the animator play the animation backwards walk or run it plays the animation half way or full way and it plays part of the idle state without it been called that means your finger is still in the on the button so it must still play backward/forwards animation over and over . here is the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerController : MonoBehaviour {
public float moveSpeed = 10f;
public float turnSpeed = 50f;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.S)) {
anim.SetBool ("isIdle", false);
anim.SetBool ("isWalkingBack", true);
transform.Translate (-Vector3.forward * moveSpeed * Time.deltaTime);
}
else
{
anim.SetBool ("isIdle", true);
anim.SetBool ("isWalkingBack", false);
}
if (Input.GetKey (KeyCode.W)) {
anim.SetBool ("isRunning", true);
anim.SetBool ("isIdle", false);
transform.Translate (Vector3.forward * moveSpeed * Time.deltaTime);
}
else
{
anim.SetBool ("isRunning", false);
anim.SetBool ("isIdle", true);
}
}
}
`