Continuous keydown in Animator
Hi all,
I'm working on a project where I have a character that has two animation states one for falling and one for floating. Inside the animator contoller, these are attached by one transition from floating to falling with no exit time. each state is set on loop. What I want is whenever the w is keydown the floating animations should play. And as soon the w is key up the falling animation to play. I have been plahing with the code and what i got is for the w key if hit once to play the floating animation and then once done "Loop option is removed" then it goes back to falling. But what I want something smoother. especially that the w will be hit continuously. My current code looks like this. And it is not working.
Your help is much appreciated.
using UnityEngine; using System.Collections;
public class HandOnOff : MonoBehaviour {
Animator anim;
void Start () {
anim = GetComponent<Animator> ();
}
void Update () {
if (Input.GetKeyDown ("w")) {
anim.Play ("Floating");
} else {
anim.Play ("Falling", -1, 0f);
}
}
}