Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question GetKeyDown not recognizing (any) inputs on Mac, where the same code works on PC!?!?!

Discussion in 'macOS' started by DjArTiStRy, Jan 17, 2023.

  1. DjArTiStRy

    DjArTiStRy

    Joined:
    Jan 17, 2023
    Posts:
    2
    I'm trying to do the simplest thing; make a capsule jump by pressing space, and I've copied a code that works on my Windows machine. Code is:

    void update()
    {
    if (Input.GetKeyDown(KeyCode.Space))
    {
    GetComponent<RigidBody>().AddForce(Vector3.up *5, ForceMode.VelocityChange);
    }
    }

    But for some reason, it doesn't seem to register pressing the space bar! Capsule doesn't move at all. In fact, it doesn't seem to register any keys being pressed! I've tried swapping in other keys, but none of them seem to be register. I've also tried to write a debug.log that registers the key press in the console, but nothing is reported while the 'game' is running and I press the assigned key. It seems that Unity is not registering any inputs.

    Using 2021 16 Inch MacBook Pro (M1), Monterey 12.3, Unity 2021 3.16f1, Visual Studio 2022 for Mac...

    Any idea what I might be missing? Is it a Mac thing? Is there some setting I've not setup right? Is it the code, something in Unity, Visual Studio, or a version thing?

    Any help would be wonderful! Also, I'm a total beginner and this is so frustrating because it just worked first try on my PC!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,516
    It's supposed to be "Update" not "update" (capitalized "U").
     
  3. DjArTiStRy

    DjArTiStRy

    Joined:
    Jan 17, 2023
    Posts:
    2
    Thanks for the reply! Sadly, I transcribed it poorly.. it is in fact capitalized in the code. 'Update' is in yellow.

    Any other ideas?