Build a UI Minimap in Unity

Mario lopez
3 min readAug 9, 2023

--

First put a image on the top right of your screen for the map then put a 2nd image that represent the player then mask the map image so you see the middle of it then make another image that represent a object.

Note: If you dont know how to mask a ui image click here to find out

Now make a Manager for the mini map then make a script for it call mini map

Now open it then before we doing anything put using UnityEngine.UI so we can get the ui. Now get the player object then the other object then the map image pos and other object pos.

Now in void update get the rect transform of the map image make it equal a new vector 3 with X position will be set on the player X position the Y Possition will be set on the player Z Position this is so if the player move on the Z the image will go up and down.

note: The negative 1 is to make the image go the right way so when you go left the image goes left etc. without this your image will go the opposite way when you move left to right.

Then for the other object do the same thing.

See you next time.

--

--