Objective: Let’s take our Minimap to the next level by adding some moving icons.
For this article I would like to make sure our 3D enemies have icons above their heads so that we can follow them in real time on our minimap.
We have a couple options to set this up:
- We can use mathematics to take the 3D coordinates and convert them to 2D and tell the minimap icons to move this way. Alternatively,
- Use Quads and add a material icon.
For this article I am going with option 2.
Step 1 — Adding a Quad to the Enemy and Editing Settings
With your ‘Enemy’ highlighted in the Hierarchy window, right-click on the GameObject and add 3D → Quad.
This will make it a child to your enemy.
For this particular feature to work we want to flip the rotation so that the Z-Axis is face down (by adjusting the X-rotation) so that when we add the material, we will see it face down. We also need to place it higher than the ‘Enemy’ GameObject.
While we are here, let’s change the Layer to Minimap.
Step 2 — Creating a Material with a Enemy Icon
Right-click in the Project window → Create → Material → Name: BlinkyMinimapIcon.
Drag this new material into the “Materials” field on the Mesh Renderer component.
Step 3 — Material Settings
Now, one of the most important steps is to get the settings right on this material to give us our desired outcome. This is our desired settings for this particular feature:
Rendering Mode — Set this to Transparent
Albedo — Set as a white background and drag and drop your sprite image that you want to use into the little box. (make sure your sprite has an alpha channel or this won’t work).
Metallic & Smoothness — 0
Source — Metallic Alpha
Specular Highlights — Unticked. This was the setting that finally gave me my desired outcome and I will show you what I mean:
There was always this faint shadow box in the background that was showing up on the minimap making the aesthetics very unappealing.
However, turning this off was the key to my solution:
Now as the icons moved around the minimap, there was no faint box following them around.
Step 4 — Adjusting Additional Settings on the Quad Game Object
We can turn a lot of the additional settings off for this Quad as we don’t want light sources to be affecting this GameObject.
For the Mesh Collider, set this to Convex and IsTrigger. We don’t want these Quads colliding with each other as the enemies move around the map.
Step 5 — Locking the Icons Rotation
Currently as the enemies move around the map they rotate with their GameObject. To create that nostalgic feel of the original Pacman we want to lock the icons rotation.
Create a new script — ‘IconRotationLock’ and add this to the Quad.
In FixedUpdate(), let’s set the Y-rotation to be 0 at all times.
Part 03 will look at building a Zoom In/Out feature for the Minimap to give the player more flexibility in how they want to view the Minimap.