- Home /
How to convert GPS Lat-long co-ordinates into Unity co-ordinates?
I am building an application in which the user's real time movement has to replicated in my virtual game world. I was able to fetch the user's current LocationInfo (Lat-long co-ordinates) through Input.LocationService.
As the user moves in real-world, I am getting the updated LocationInfo. But how do I update the virtual character in my game world to move in the same direction and distance as the user?
Thanks in advance.
Answer by tanoshimi · Jul 27, 2016 at 09:56 AM
Lat/Long are spherical coordinates (well, elliptical, really), but I'm assuming your game world is flat. You therefore need to employ some form of projection.
The simplest is an equirectangular projection:
position.x = longitude
position.z = latitude
Thank you for the quick answer. It gives the basic idea of how to do it.
Regarding the equi-rectangular projection, if I multiply the latitude and longitude with a constant value (say 100) and use it as the unity co-ordinate for my user character, I can move my object with respect to the user's location right? Am I missing or misunderstanding something here?
Apologies if my understanding is wrong,
Latitude is an angle measured in degrees above or below the equator. North pole is +90 latitude, south pole is -90. Longitude is an angle measured around the earth from the prime meridian. East extends positively, west negative, to +/- 180.
You can multiply by any arbitrary constant you want to apply a scaling.