Topic: Unity space to world space + inverse

How can I go from Unity coordinates to real world coordinates and vice versa?

For example I want to create 1000 gameobjects and I need them to be at Lat Lng 51,-1.

Re: Unity space to world space + inverse

Hello.

OnlineMapsControlBase.GetScreenPosition:
Geographical coordinate to screen space.
http://infinity-code.com/doxygen/online … c82e3a5f04

OnlineMapsControlBase.GetCoords:
Screen space to geographical coordinates.
http://infinity-code.com/doxygen/online … b99f610155

OnlineMapsControlBase.GetPosition:
Converts geographical coordinate to position in the scene relative to the top-left corner of the map in map space.
http://infinity-code.com/doxygen/online … 0028781fe8

OnlineMapsTileSetControl.GetCoordsByWorldPosition:
Returns the geographical coordinates by world position.
http://infinity-code.com/doxygen/online … 7316430ad9

OnlineMapsTileSetControl.GetWorldPosition:
Converts geographical coordinates to position in world space.
http://infinity-code.com/doxygen/online … ea663abc1f

OnlineMapsTileSetControl.GetWorldPositionWithElevation:
Converts geographical coordinates to position in world space with elevation.
http://infinity-code.com/doxygen/online … 3632bad690

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Unity space to world space + inverse

Consider: https://en.wikipedia.org/wiki/Decimal_degrees

Is there a double implementation? I would like centimeter level accuracy.

Re: Unity space to world space + inverse

Yes, almost every method (where necessary) has an overload double precision.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Unity space to world space + inverse

I don't see the double implementation for these methods.

Re: Unity space to world space + inverse

bool OnlineMapsControlBase.GetCoords (out double  lng, out double  lat, Vector2 position)    
http://infinity-code.com/doxygen/online … 4fd5a5a0e1

bool OnlineMapsTileSetControl.GetCoordsByWorldPosition (out double lng, out double lat, Vector3 position)
http://infinity-code.com/doxygen/online … 1b58011257

Online Maps v2.3 beta (available through the built-in update):
void OnlineMapsControlBase.GetPosition(double lng, double lat, out double px, out double py)
Vector2 OnlineMapsControlBase.GetScreenPosition(double lng, double lat)
Vector3 OnlineMapsTileSetControl.GetWorldPosition(double lng, double lat)
Vector3 OnlineMapsTileSetControl.GetWorldPositionWithElevation(double lng, double lat, double tlx, double tly, double brx, double bry)

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

7 (edited by cshiel 2015-11-24 02:32:02)

Re: Unity space to world space + inverse

I am trying this with the tile example, trying to put in a gameobject around Brisbane.

GameObject newEntity = null;
newEntity = GameObject.Instantiate(pedTemplate);
var unityPosition = OnlineMapsControlBase.instance.GetScreenPosition(new Vector2(-27.52188f, 153.0187f));
newEntity.transform.position = unityPosition;

and

newEntity.transform.position = new Vector3(unityPosition.x, 0, unityPosition.y);

Its not putting the object in the correct place.

Re: Unity space to world space + inverse

cshiel wrote:

new Vector2 (-27.52188f, 153.0187f)

It's wrong. X - longitude, Y - latitude.


cshiel wrote:

newEntity.transform.position = unityPosition;

Screen space is not equal World space.
No matter what you are using GUI, uGUI, Tileset.
It is always wrong.
For tileset use GetWorldPosition.
For the other controls: you need to convert screen position to world position.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.