Location service not updating the input value
My Problem: After the initial start the program will fetch the location once and than repeat getting the same location over and over again. If I leave the app (not close but have it run in the background) and go back in it will update the location (only once as well).
int i = 0;
while (!Input.location.isEnabledByUser)
{
Debug.Log(SystemInfo.deviceName);
//textMesh.SetText(SystemInfo.deviceName);
Permission.RequestUserPermission(Permission.FineLocation);
yield return new WaitForSeconds(1);
//textMesh.text = i + " Error";
Debug.LogError("Failed to start gps! Is it enabled?");
//TextMesh.text = "No GPS (" + i + ")";
this.Location = null;
yield return new WaitForSeconds(5);
i++;
}
Input.location.Start(1, 0.1f);
while (Input.location.status == LocationServiceStatus.Initializing)
{
yield return new WaitForSeconds(0.2f);
}
while (Input.location.status == LocationServiceStatus.Running)
{
this.Location = new Location(
Input.location.lastData.latitude,
Input.location.lastData.longitude,
Input.location.lastData.altitude,
Input.location.lastData.horizontalAccuracy,
Input.location.lastData.timestamp);
}
This behaviour is pretty weird as it should at least at some point update the location. I moved about 20 meters and nothing happens. To test things I tryed fetching the location once than stopping the service just to start it again. Get the value back and do that endlessly. That works although ofc the gps symbol flickers values tak jump around a bit.
As far as I know my code piece should usually keep the location updated unless it cancels (this will call some other script notifying me though, which is not the case).
Your answer
Follow this Question
Related Questions
Location Service gets stuck during Initializing on Epson Moverio 1 Answer
GPS power consumption 0 Answers
how to access “device only” gps in Unity 0 Answers
Trying to Build GPS Tracking Based App, Help 0 Answers
Input.location GPS issue 1 Answer