GPS-Based-AR
GPS-Based-AR copied to clipboard
How to spawn a GameObject through GPSCoordinates?
I know the project is a bit outdated (2017) for the Unity 2019 version, but it doesn't matter. You use the FlyingDisk or the GiftBox prefabs that are already positioned in the 3D viewport. But how using GPS coordinates would you create an instance of one of these two prefabs in a 3D world position? And that when moving with the device the real distance is maintained?
I can convert GPS coordinates to cartesian like this (python code):
import numpy as np
def get_cartesian(lat=None,lon=None):
lat, lon = np.deg2rad(lat), np.deg2rad(lon)
R = 6371 # radius of the earth
x = R * np.cos(lat) * np.cos(lon)
y = R * np.cos(lat) * np.sin(lon)
z = R *np.sin(lat)
return x,y,z
But in the viewport the distances are shorter than in reality.
Greetings.