If I don’t bump the model (not the player) walking around the scene the script works fine.
But if I bump the model with my character controller the model will continue to move once it hits the waiting animation state.
Why would that happen? How can i fix it?
public class MoveMan2 : MonoBehaviour
{
public float speed = 0.85f;
public Animator anim;
void Start()
{
anim = GetComponent<Animator>();
InvokeRepeating("SetWalkMode",5.0f,20.0f);
}
void SetWalkMode()
{
anim.Play("SkitsWalk", -1, 0f);
}
void Update()
{
if (anim.GetCurrentAnimatorStateInfo(0).IsName("SkitsWalk"))
{
Debug.Log("Skits walking");
transform.Translate(0, 0, speed * Time.deltaTime);
}
if (anim.GetCurrentAnimatorStateInfo(0).IsName("Wait"))
{
Debug.Log("Waiting");
}
}
}