Search Unity

Location/GPS tracking with new input system.

Discussion in 'Input System' started by RobbertGroenendijk, Apr 9, 2021.

  1. RobbertGroenendijk

    RobbertGroenendijk

    Joined:
    Sep 12, 2018
    Posts:
    10
    I have been prototyping a project that uses location tracking in the old input system (https://docs.unity3d.com/ScriptReference/LocationService.Start.html). I switched to the new input system to be able to use enhanced touch and the pedometer. However, I can not find any way to use the locationservices within the new input system.

    All examples of getting location/tracking data use; Input.loction.status etc. But when you are using the new input system one shouldn't use the Input. class at all. I have had location working before on the Android device i am developing for so it should be working fine. However, it always gets stuck initialising.

    Does anyone have a pointer on this?
     
    tealm likes this.
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,066
    Did you try disabling the old input manager and see if
    Input.location
    still works? I would guess it does, as it's not really part of either the old or new input system and was just put on the
    Input
    class since it was handling some other sensor inputs already.

    The reason why you shouldn't use the old
    Input
    class is because things might stop working if you disable the old input manager. But there are quite a few properties on there that don't really belong to the old input manager and that you'll have to continue using until Unity changes the API (e.g. compass, device orientation, location or back button handling).
     
  3. RobbertGroenendijk

    RobbertGroenendijk

    Joined:
    Sep 12, 2018
    Posts:
    10
    Well ye i think only one can be really 'active'. At least in the player settings, the Active Input Handling is now set to the new input systems package, and Input.location doesn't seem to work (or at least doesnt finish initialising). I also tried just making a LocationService object, and then just activating everything through that but that has the same problem. So I guess they are strangely dependent on each other.

    I got all the other sensors working, like gyroscope, pedometer, accelerometer and such. But there is also no documentation for location-data within the Scripting API of the new input system.
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,435
    in recent versions (not sure from where it started) can apparently have both enabled,
    upload_2021-4-9_16-9-1.png
    *screenshot from 2020.2.7f1
     
  5. jaiwithani

    jaiwithani

    Joined:
    Jun 12, 2020
    Posts:
    2
    I'm also interested in this. I'm using "Both" for now, but it means that I'm still going to be using `Input` wherever location is concerned in my code, tying me to the legacy stuff. Location isn't even mentioned in the known limitations page, and I've been unable to find any location documentation that doesn't rely on the old system.
     
    tealm and Cery_ like this.
  6. Paul_Bonnel

    Paul_Bonnel

    Joined:
    Sep 16, 2017
    Posts:
    2
    Setting "Active Imput Handling" to "Both" work for us! Thanks!
     
    CodeFluegel2 likes this.
  7. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Any news from Unity when we can expect to have Location support in the new Input system?
     
  8. moritz_jaeger

    moritz_jaeger

    Joined:
    Jun 15, 2015
    Posts:
    7
    Still no news on this?

    I just wasted a lot time trying to figure out why I didn't get GPS location updates in Android builds.
    Only after step by step removing everything from my project and flipping all project settings on and off, I figured out it had something to do with the Input System :(

    And if this isn't a bug, maybe at least show us an error message when you try to use Input.location with only new input system active....

    https://docs.unity3d.com/Packages/c...csunity3dcomscriptreferenceinput-locationhtml
    input_system_location.jpg
     
    Last edited: Oct 25, 2022
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    Wouldn't you be better off asking in the Input System forum itself rather than the general scripting forum?

    It's not like the Unity team involved with Input would be looking at this so it's unclear who you're trying to talk to.

    I'll move this thread to the Input System. Maybe someone then will spot it.
     
  10. moritz_jaeger

    moritz_jaeger

    Joined:
    Jun 15, 2015
    Posts:
    7
    Hi, thanks a lot for moving the thread.

    Often times people just find these threads through Google search and just add to it without even looking at the forum they are in. Just how I did a few minutes ago. Sorry about that! :)
     
  11. kayy

    kayy

    Joined:
    Jul 26, 2011
    Posts:
    110
    Hi. I just ran into this issue with an Galaxy Tab S8 on Android 12, Unity 2022.1.23.
    The only way to use LocationService is to set Active Input Handling to 'Both'. Setting 'New Input System' makes LocationService hanging in Initializing state reproducibly.
    On iOS everything works fine. So it seems Android specific.

    Is there any fix planned?
     
    jhaverkost likes this.