Unity features 101: Render Textures Part 2 (in-game 2D mini-map)

Mohamed Hijazi
Geek Culture
Published in
3 min readOct 27, 2021

In part 1, we started understanding Render Textures and used them to create an in-game tv-camera; read the 1st part here: Unity features 101: Render textures part 1 (in-game tv-camera). In this part, we will take a look on how to create an in-game 2D mini-map.

2D Mini-Map Setup

A. Let’s create the image that will hold the mini-map in your UI. If you create a simple UI image, it will not work because a UI image can only accept a sprite. Instead create a UI RAW Image which can accept a Render Image.

UI Raw Image

Use Create > UI > Raw Image and position it and scale how ever you would like in your canvas.

B. Following what we have learnt in part 1, create a render texture and a new camera and set its Target Texture to the newly created render texture. Rename them to Minimap Render Texture and Minimap Camera respectively.

C. Set the minimap camera position to be above the world map in order to see the player and environment from the top. We should start seeing it come to life like this =>

Minimap

D. You should have noticed that the minimap camera is a little weird. It has some perspective, and characters and buildings are not represented as icons on the minimap. Lets fix it.

  1. Change the Projection of the minimap camera from perspective to orthographic and set its size as you want it to be.
Orthographic

2. Player icon (can be applied to any object in your scene): if the game is 2D, create a square sprite as a child of the player or if this is a 3D game, create a child quad (or whatever you want) and set its transformation so that the minicamera can see it.

In my case I created a quad minimap icon.

3. In order for the minimap camera to ONLY see the icons, create a new layer call it Minimap and assign it to minimap icons. Choose the minimap icon of the player and set its layer to Minimap.

4. Finally, choose your minimap camera, and change the Culling Mask from Everything to Minimap, this way the minimap camera can only render the minimap icons.

Result:

2D Minimap

The 2D minimap in this example has a few trees, a house, and a player. From here you can do whatever you want with your minimap and make it more atheistically pleasing.

--

--

Mohamed Hijazi
Geek Culture

A knowledge seeking biologist who is following his passion into a full time career in Unity / Game Development. https://www.linkedin.com/in/mohamed-hijazi/