Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Terrain Positioning: Use Real World Coordinates, Scale coordinates or just 0,0,0

Discussion in 'Scripting' started by gretty, Sep 23, 2013.

  1. gretty

    gretty

    Joined:
    Jun 20, 2012
    Posts:
    72
    Hello

    I would like some advice on how I should organise my game terrain. My game/application creates the terrain using Google's Static Maps. So it downloads these satellite images and tiles them together to produce a terrain. It also obtains the real world elevation using Google Elevation.

    So I download the satellite image and apply this image to a Plane GameObject as a texture. I am wondering what position I should give these Planes, ie, real world coordinates, ie, a position of -33.33222, 151.45322, 100 or just begin from 0,0,0.

    $27zj6ue.jpg

    Would you maintain the world coordinates (Longitude, Latitude, Elevation) inside the game/app or would you just tile these Planes at 0, 0, 0 and go from there? If I use world coordinates it will mean that these Planes will have a tiny scale of 0.006866455 by 0.1 by 0.006866455 (x, y, z). This is because the real world width and height (in degrees) of each satellite image is 0.006866455 degrees. This might cause some tricky collision detection down the track do you think? Ie, working with such small numbers may make collision detection less efficient? But having real world coordinates will help with setting elevation easily, ie, if the real world elevation of -33.74857, 151.2321 is 100.5 then I wont need to convert this Long, Lat to game coordinates.

    Would you maybe scale the coordinates up by a factor of 100. So a Plane representing the real world coordinate of -33.74857, 151.2321, 100 would be placed in the game at -3300.74857, 15100.2321, 10000 and the planes scale would be 0.6866455 by 10 by 0.6866455 (x, y, z). Or would you just not bother and just start placing the Planes at 0, 0, 0 with a scale of 1, 1, 1 and go from there?
     

    Attached Files:

    Last edited: Sep 23, 2013
  2. Toerktumlare

    Toerktumlare

    Joined:
    Sep 15, 2013
    Posts:
    74
    it all depends on what you have planned down the line. In the documentation it is recommended to use real world sizes for the physics engine to work properly.

    Så basically that is what sets the standard and what should dictate the size, if you are going to use physics.

    Then where you place your objects in world space really doesnt matter as long as YOU have some sort of system to know where wich tiles is where. i would try to size my tiles to a size that is easy to multiply and is same langth and width. like 1024x1024 for each tile. then maybe store tiles in an object. Stuff all these objects in an array, and each object contains the texture, the long and lats, and their actual position in world space ingame.

    but as i said, physics engine is the one dictating the size.
     
  3. gretty

    gretty

    Joined:
    Jun 20, 2012
    Posts:
    72
    Thanks for your reply :) I think I might stick to 1,1,1 scale and 0,0,0 positioning and convert game coords to world coords. Seems the easiest.
     
  4. knevagi

    knevagi

    Joined:
    Mar 18, 2018
    Posts:
    1
    Hey i am pretty new to unity and am really interested in how you did all this. Can you tell me how you learned to do this? or any available tutorial you can point me to that will help me learn this. Would really appreciate the help.
     
  5. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    193
    doesnt get simpler than this
     
unityunity