// Use this for initialization void Start() { if (CurrentPosition != Vector3.zero) { transform.localPosition = CurrentPosition; } animation = GetComponent <Animator>(); CurrentVel.Set(0, 0, 0); PrevVel = new Vector3(-0.5f, 0, 0); }
void EzioMovement() { if (Input.GetKey(KeyCode.UpArrow)) { CurrentVel = new Vector3(0, 0.05f, 0); if (PrevVel.x < 0) { animation.Play("Walk_Left"); } else { animation.Play("Walk_Right"); } } else if (Input.GetKey(KeyCode.DownArrow)) { CurrentVel = new Vector3(0, -0.05f, 0); if (PrevVel.x < 0) { animation.Play("Walk_Left"); } else { animation.Play("Walk_Right"); } } else if (Input.GetKey(KeyCode.RightArrow)) { CurrentVel = new Vector3(0.05f, 0, 0); animation.Play("Walk_Right"); PrevVel = CurrentVel; } else if (Input.GetKey(KeyCode.LeftArrow)) { CurrentVel = new Vector3(-0.05f, 0, 0); animation.Play("Walk_Left"); PrevVel = CurrentVel; } else { CurrentVel.Set(0, 0, 0); if (PrevVel.x < 0) { animation.Play("Idle_Left"); } else { animation.Play("Idle_Right"); } } }