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

How machine learning can assist testers

How to debug network issues in Unix — “nslookup”

We're under attack! 23 Node.js security best practices

Stop praising firefighting (in software).

Biggest Challenges That Developers Face in Android Platform

Ekam Intellisense

Guiding the scenes of 300

Configuring MySQL NDB Cluster by using Docker and pointing with WSO2 APIM

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

Lighting your scene in Unity using the URP

Cross platform input controller | Unity

Point and Click Controller in Unity

Create a Diablo Style Character Controller in Unity!