Implementing a 2D world map with different levels of detail

Hi, I want to create a world map with these requirements:
. 2D top down view
. the map is scrollable and zoomable. Different levels of detail are visible when zooming (for example I want to show only major city names where viewing the full map, adding more city names when zooming in)
. the map is static, I want to create it with an external tool. No need of randomness or procedural content generation
. the map, at the highest detail level, can have a huge resolution so I’m not sure if I can use a single texture.

What is in you opinion the best way to implement this in Unity?

Thanks a lot for you kind answers!

Aury

You could use raycasting to see how far away of the map the camera is. If the camera is, let's say, less than 3 feet away from the map, you'd use a different material/sprite for your map, depending on which you use of course. I'd recommend taking a look at raycasting from the documentation, aswell as sprite/mesh renderers, again, depending on which you use.

1 Answer

1
  • Fix the camera on a plane(ie: z = 0).
  • Even though the camera is fixed to a plane, you can still rotate it.
  • Keep the map parallel to that plane.
  • Calculate the distance of the plane from the camera(ie: z_map - z_camera).
  • On your objects that display the map, Add a function that takes that value.
  • Track the last value to know if you have triggered any changes.
  • Enable and Disable renderers to hide and show different objects.

Something Like This:

void UpdateZoom(float distance){
  if(distance > 100 && lastDistance <= 100){
    HideCloseDetails();
  }
  else if(distance < 100 && lastDistance >= 100){
    ShowCloseDetails();
  }
  lastDistance = distance;
}