- Home /
Duplicate of http://answers.unity3d.com/questions/379001/how-can-i-tell-unity-to-wait-to-do-something-until-1.html
How can I tell Unity to wait to do something until after and animation has finished playing?
I have a cube type character that rolls on the screen, each time a key is pressed it roles in the respective direction. I can't seem to figure out how to tell unity to wait until the animation has finished before allowing more keys to be pressed. Here is what I have so far.
pragma strict
public var W : GameObject; public var A : GameObject; public var S : GameObject; public var D : GameObject;
function Start () {
}
function Update(){ if(Input.GetKeyUp("d")){ animation.Play("Move(D)"); transform.position.x = transform.position.x + 10; D.active = true; W.active = false; A.active = false; S.active = false; } if(Input.GetKeyUp("a")){ animation.Play("Move(A)"); transform.position.x = transform.position.x - 10; A.active = true; W.active = false; S.active = false; D.active = false; } if(Input.GetKeyUp("w")){ animation.Play("Move(W)"); transform.position.z = transform.position.z + 10; W.active = true; A.active = false; S.active = false; D.active = false; } if(Input.GetKeyUp("s")){ animation.Play("Move(S)"); transform.position.z = transform.position.z - 10; S.active = true; W.active = false; A.active = false; D.active = false; } }