Geek Culture
Published in

Geek Culture

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

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.

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Dedicated SQL pools in Azure Synapse Analytics

Space Project: Rumor has it

A Ballpark Look at the Cost of Making an App 2022

A JavaScript Dev’s Origin Story

A closeup of a laptop and a cup of coffee

Technical Data Roadmap: Why and how to build it using a maturity matrix?

Kotlin Vs Java : Basic Syntax Differences

Making a Virtual War Room — the Journey to ChatOps

A real war room — Sailors visit the Churchill War Rooms Museum in London (US Navy)

What is Tensorflow ?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mohamed Hijazi

Mohamed Hijazi

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/

More from Medium

Creating an Office Den in Unity Part 3: The Icing on the Cake

Using Decals in Unity

Creating a Beautiful Level in Unity

Adding a new ability to our prototype — The Triple Shot