- Home /
Question by
nYTskYz · Feb 16, 2014 at 05:56 PM ·
inputinputmanager
How can I get user-defined inputs?
Iv'e been wondering if I can get the user-defined button values and use it in some parts of the game. For example, if player is near to a pickable object the GUI label would say
"Press [the user-defined button] to pick up [pickable object name]".
Iv'e been seeing it in most games. Any ideas will be appreciated, thanks and pardon me if I'm a novice.
Comment
Answer by robertbu · Feb 16, 2014 at 06:29 PM
This all depends on how you implement re-defining keys by the user. For example if you use KeyCodes:
#pragma strict
var jumpKey = KeyCode.J;
function Start() {
Debug.Log("Press the '"+jumpKey+"' key");
}
function Update() {
if (Input.GetKeyDown(jumpKey)) {
Debug.Log("Do a jump");
}
}