Today I am going to share a very interesting topic with you. We all use this in our normal daily life, But at that time non of us try to know how we can do this. How I will check this. How I come to know about this.
Yes, I am talking about the GPS system. GPS shows complete information about your location, area and all.
Now in these days people have had started creating games with GPS. So I am sure in everyone's mind there will be a question, how I can do this? How can I implement GPS in my game or app?
So here is the solution:
We can now easily add GPS in our games or app bu following code packet. We can check the location very easily.
public class Sps : MonoBehaviour
// First, check if user has location service enabled
// Start service before querying location
// Wait until service initializes
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
yield return new WaitForSeconds(1);
// Service didn't initialize in 20 seconds
if (maxWait < 1)
// Connection has failed
if (Input.location.status == LocationServiceStatus.Failed)
print("Unable to determine device location");
// Access granted and location value could be retrieved
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
// Stop service if there is no need to query location updates continuously