Reputation: 919
I cannot detect if space-bar
key was pressed, I have following code:
void Update() {
// Working
if (Input.anyKeyDown) {
Debug.Log("anyKeyDown");
}
// Not working
if (Input.GetButtonDown("Jump")) {
Debug.Log("GetButtonDown - Jump");
}
// Not working
if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("space")) {
Debug.Log("KeyCode.Space");
}
// Working
if (Input.GetKeyDown(KeyCode.A)) {
Debug.Log("A");
}
}
I can detect if e.g. A
was clicked but its not working for Input.GetButtonDown("Jump")
or for Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("space")
Below you can see image from my console:
I am using default unity Input Manager
settings, I can see two Jumps
configured:
Upvotes: 1
Views: 14279
Reputation: 1
try using CrossPlatformInputManager
if (CrossPlatformInputManager.GetButton("Space")) {
Debug.Log("Jump pressed");
}
Upvotes: 0
Reputation: 66
Maybe do not use 2 Jumps declarations in the input editor. Make one and select its axis to X.
if (Input.GetKeyDown(KeyCode.Space))
{
}
Upvotes: 1
Reputation: 51
Have you considered using
if (Input.GetKeyDown("space"))
{
Debug.Log("space key was pressed");
}
instead?
Upvotes: 0