1 (edited by danielesuppo 2019-05-11 21:25:36)

Topic: Update multiple positions on maps

Hello,
I have hundreds of childGameobjects placed on my map.
All of them are parented to a rootGameobject.

The root.position is (0,0,0), the root.localScale is (1,1,1),
and I initialize them with "GetWorldPositionWithElevation", because I know their real longitude/latitude.

When I pan or zoom the map I'd like their positions to be updated, but if I call "GetWorldPositionWithElevation" for each of them on "OnChangeZoom" and "OnChangePosition" events  I have a huge performance issue.

I can translate my rootGameobject on the basis of the map translation (OnlineMaps.position), but the translation combined with the map zoom is giving to me a lot of struggles.

Is there a "right" way  to update the position of all my gameobjetcs in one go, on the basis of map translation and map zoom, in reference to a root transform?

Many thanks!

Re: Update multiple positions on maps

Hello.

Theoretically, you can greatly optimize calculations in this way:
1. Calculate the coordinates of the borders of your GameObject (find the top-left coordinate and bottom-right coordinate).
2. When OnChangeZoom and OnChangePosition, find the tile position and unity world position of your corners.
3. Convert the coordinates of each GameObject to a tile position, find the relative tile position of the GameObject and, based on this, find the unity world position of GameObject.
4. If the GameObject is inside the map view, get elevation.

Kind Regards,
Infinity Code Team.

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