Hi guys,
So i made a character on blender and animated it etc. Now when i implemented the animations in the movement on unity it kinda does not respond instantly. About only 1 second later it changes animation when detecting if player changed a key. Heres the code:
using UnityEngine;
using System.Collections;
public class Animation : MonoBehaviour {
private int estado;
private Animator animation;
// Use this for initialization
void Start () {
animation = GetComponentInChildren<Animator>();
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("w")) {
estado = 1;
animation.SetInteger ("Estado", estado);
}
if (Input.GetKey (KeyCode.LeftShift) && estado == 1) {
estado = 2;
animation.SetInteger ("Estado", estado);
}
if (Input.GetKeyUp (KeyCode.LeftShift) && estado == 2) {
if (Input.GetKeyDown ("w")) {
estado = 1;
animation.SetInteger ("Estado", estado);
} else {
estado = 1;
animation.SetInteger ("Estado", estado);
}
}
if (Input.GetKeyUp ("w") && estado == 1) {
estado = 0;
animation.SetInteger ("Estado", estado);
}
}
}