Hi all!
Currently making a simple first game in Unity.
When the user uses a key, the character should jump (2D game btw). However, the space bar and left click are not registering. When I use anyKeyDown it detects every other key I’ve tried. The space bar, when used, interacts with Unity instead of the game ie. opens a drop down menu in the game window. Mouse click does something along the same lines. Same happens when use Input.GetKeyDown(KeyCode.Space) and Input.GetMouseButtonDown(0), respectively.
if you go to edit—project settings—input it should tell you what you can type for space or ‘‘jump’’.
if you need a simple 2d jump script see if this works
public float jumpForce = 7.5f;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpForce);
}
}
Interesting. The behaviour you describe is present if you have toggled sticky keys to be on. In which case pressing space will act as a menu open instead of a standard key press.
If you are on windows check under accessibility, that you don’t have sticky keys or any of those settings enabled. Not sure where this setting lives on a mac.
I am having the same issue with using space button, though I do not get a menu action from using it. Have not tested this with the left mouse so far. If you find a fix I would love to know.