Search Unity

latitude longitude shows 0 0

Discussion in 'General Discussion' started by alexchandriyaa, May 29, 2018.

  1. alexchandriyaa

    alexchandriyaa

    Joined:
    Jan 18, 2017
    Posts:
    140
    i have to find current latitude and longitude if i run this it shows zero always both in phone and editor

    Code (CSharp):
    1. public void Start()
    2. {
    3.          Input.location.Start ();
    4.         Input.compass.enabled = true;
    5.         lat = Input.location.lastData.latitude;
    6.         Debug.Log (lat);
    7.         lon = Input.location.lastData.longitude;
    8.         Debug.Log (lon);
    9. }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    My guess would be because Input.location.Start does not start the location service on the same frame you call it.

    https://docs.unity3d.com/ScriptReference/LocationService.Start.html