This tutorial is about adding a minimap to your game, with as less extra work as possible.
We came up with this technique during a hack on our game prototype Good Old Days, and it took us only a few hours to develop.
It mostly consists of adding a top-down camera and render it into a UI element. This tutorial will show all the steps to achieve it, and it requires no scripting at all.
1. Setup a top-down camera
First add a new camera into your scene and set it up this way:
2. Render into texture
Create a render texture asset in your project, using these settings:
Set your minimap camera to render into this texture instead of the screen.
3. Display as UI element
On your main game camera, add a Canvas and set it up for this camera:
Create a render material for the UI element and set it up this way:
For the UI element itself, make a circle mesh (or whatever other shape you prefer) and add it into your canvas. You can make one easily using Blender, or use a thin cylinder in Unity.
Then you'll have to:
Now your minimap will show up in game, and display your environment from a top-down perspective! In order to follow the player, you can easily move and rotate the camera, and also change its orthographic size to change the zoom level.
4. (Optional) Specific visuals
This last part explains how to use custom visuals for the minimap instead of rendering the game directly, in case your assets are not ready to be viewed in a top-down perspective, or you want a mix of game elements and specific UI elements.
First create some objects in your game world that you want to render in your minimap, on the same coordinates your game objects are.
Their height doesn't matter since they are going to be rendered using an orthographic camera, so you can put them under or above your game objects.
Set their layer as "UI" (or any specific layer of your choice).
In the following example, we've added some tiles to be rendered in the minimap instead of the environement, plus a black background far away under the scene.
After adding these objects you just need to setup your main game camera to ignore this minimap layer:
And (depending what you need) you can setup the minimap camera to draw only the minimap layer:
Here's the final result. As easy as promised, isn't it?