- Home /
How to activate someting if a key is held down?
greetings, i want to have a feature in my game where if the player is within a box collider they can hold down a key and jump through a window. so pretty much, i need to know the function of;
"if a key is held down" { Animation.play("Animation"); }
Comment
Answer by Julien-Lynge · Jan 10, 2013 at 06:58 PM
Take a look at the Input class. The answer is there:
http://docs.unity3d.com/Documentation/ScriptReference/Input.html
Take a look at the class functions.
Answer by Azial · Mar 11, 2013 at 05:54 PM
if (Input.GetKey(keyNum.ToString()) {…}
'keyNum' can be any key you want e.g. var keyNum : int = 1; or var keyNum : String = "k";