Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[New Input System] Current Device

Discussion in 'Input System' started by opdenis, May 6, 2020.

  1. opdenis

    opdenis

    Joined:
    Jan 23, 2017
    Posts:
    15
    ok, I could not get working StepCounter, so I started from the beginning - the tutorials.
    I opened the manual:
    https://docs.unity3d.com/Packages/c...pi/UnityEngine.InputSystem.Accelerometer.html
    So I copied and pasted the code:
    Code (CSharp):
    1.     protected void OnEnable()
    2.     {
    3.         // All sensors start out disabled so they have to manually be enabled first.
    4.         InputSystem.EnableDevice(Accelerometer.current);
    5.     }
    Run and open LogCat:
    What's the problem with SENSORS? Does somebody know how to get them to work?
     
    Virtumonde and js3422 like this.
  2. frpe1

    frpe1

    Joined:
    May 4, 2020
    Posts:
    10
    I though it was an error to, but on my device when running the app, it works just fine. But when pressing play in unity I get this result. Not sure if that was the case for you, but handling with an try-catch could come in handy or simple use

    if (Accelerometer.current != null)
    InputSystem.EnableDevice(Accelerometer.current);

    That did the trick for me