# how to convert gps coordinates to unity

hello.
first, my english skill is not good. sorry…
anyway i want to convert lat/lon to unity x,y coordinates.
i already read some another questions but not solved…

i made c# script to get the gps data and it works well.
i also made a object in the unity world, and made another c# script to control camera rotation with gyro.
and!! last!!
i just want to move my unity camera according to gps lat/lon data.
so i convert my lat/lon data.
https://stackoverflow.com/questions/32311647/converting-gps-coordinates-to-x-y-z-coordinates
but, my camera is not moved as i wanted.
problem is this.
lat, lon is correct, but converted data(x/z) is incorrect.

float latToZ (double lat){

``````lat = (lat - 53.178469) / 0.00001 * 0.12179047095976932582726898256213;
double z = lat;

return (float)z;
``````

}

float lonToX (double lon){

``````lon = (lon - 6.503091) / 0.000001 * 0.00728553580298947812081345114627;
double x = lon;

return (float)x;
``````

}
i think in this function, the equation is little wrong…
please someone make me know how can i convert that.

thanks and have a good day

if I understand StackOverflow answer correct, that means these " 6.503091 & 53.178469" has nothing to do with you, and you should calculate this numbers for yourself.

I suggest,

1- pin point your position on a “real map”, and mark that position in “unity map”,

2- make public variables for these numbers ( 6.503091 & 53.178469) and make a UI slider for changing them

3- Build and install, hit play, try to adjust your camera view with those UI sliders you made for ‘these numbers’

4- once you satisfy for your position, note that sliders value.

5- Go back to unity and enter numbers that you note into the equations.

and don’t forget to notify us about results.