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.

1 Answer

1

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,