GPS-Based-AR icon indicating copy to clipboard operation
GPS-Based-AR copied to clipboard

How to spawn a GameObject through GPSCoordinates?

Open helghast opened this issue 5 years ago • 0 comments

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.

helghast avatar Jul 13 '20 15:07 helghast