Problem with change of resolution in minimap

Hi

Here’s my problem: i have a working minimap in my tower defence project by using a secondary camera on top of my scene (see first image). This camera only shows the terrain but i calculate the position of certain elements in the scene (enemies, towers, etc) and show them with tiny icons. I also can move the camera by clicking on the minimap.

All this works perfectly but only if i keep my default resolution, if i change it these icons (or blips if you prefer) just move away of their positions. I know this is a common issue and i did solve it for the other gui elements by using GUI.matrix but in this case, it doesn’t help me.

Here’s some sample code that shows an icon in the relative position of a castle, mapCamera is my secondary camera and castleBlip is the small texture of the icon.

auxPosition = mapCamera.WorldToScreenPoint(castle.transform.position);
GUI.DrawTexture(new Rect(auxPosition.x - (castleBlip.width / 2), (defaultVerticalResolution - auxPosition.y) - (castleBlip.height / 2), castleBlip.width, castleBlip.height), castleBlip);

These images are the minimap and a screenshot of the game:

I imagine the solution must be really simple but i suck at calculating relative positions.

Regards.

I don’t know if this would work, but instead of that method, you could have the icons attached to each unit in the actual hierarchy/world space, and put them in a separate layer that only the minimap camera renders, but not the main camera…

Sorry if this isn’t the solution you’re looking for.

Thanks for your answer… at first, your solution sounded kind of odd to me but i’m starting to like it, i think i’ll try it, thanks.