Menu

Unity3D – Simplest Circular MiniMap creation from scratch Short Tutorial | Free Demo Project included | Part 1

0 Comments


A very precise and up to the point tutorial on how to create a Circular Minimap in Unity3D. This tutorial is designed from scratch, but if you have your game already built up, don’t worry, you’ll be able to integrate this minimap into your already made game.

And if you want to start fresh, you can download the Demo Project for free at the bottom of the post.

Setup:

I assume that you have at least very basic environment in unity (maybe only a plane and a Player and some dummy enemies). So, if you have these things setup, lets make a minimap now.

If you don’t have this setup, just create a plane and a cube in the center, and add a C# Script to that Player Cube, and add the following code into the C# Script. That’s it, you’ll have your player cube moving by arrow keys.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

	public float Speed;

	void Update () {
		if (Input.GetKey (KeyCode.UpArrow))
			transform.Translate (Speed, 0, 0);
		if (Input.GetKey (KeyCode.DownArrow))
			transform.Translate (-Speed, 0, 0);
		if (Input.GetKey (KeyCode.LeftArrow))
			transform.Translate (0, 0, Speed);
		if (Input.GetKey (KeyCode.RightArrow))
			transform.Translate (0, 0, -Speed);
	}
}

Download the Script HERE.

And in the inspector, just give it a Speed parameter like, Speed = 0.25

Steps for Minimap:

  • Create an empty GameObject as a Player child, and add Sprite Renderer as its component. Add a circle and give it a unique color. And adjust its size and rotation so that, it can be seen from upwards
  • This Sprite Renderer will be shown on the MiniMap in place of your actual player
  • Add a layer named MiniMap
  • Any GameObject on this layer, will be rendered by our MiniMap camera that we’ll create just now
  • Create a new Camera and change its projection to Orthographic. And Change its rotation so that it looks downwards
  • Change its size (not the scale) so that, it covers the area that you want it to show (maybe full map, or maybe just a small area around your Player)
  • Now change its culling mask from everything to only MiniMap
  • Select Main Camera and change its culling mask so that it renders everything except MiniMap layer
  • Depth of MiniMap Camera should be higher than that of Main Camera.
  • Now, create a new Render Texture (in your Project view), and name it MiniMapRT
  • Create a UI Canvas in your scene. And Create a Raw Image (not a normal Image). Now in its Texture field, assign the newly created MiniMapRT
  • Go to MiniMap Camera and change its Clear Flags to Solid Color and then change its Background color to Black. And its alpha to around 200 (255 if you want MiniMap to be opaque)
  • Now go to 2D mode and adjust the position of Raw Image where you want your MiniMap to appear in your Game Screen

That’s all for the very basic Setup of MiniMap.

To download the complete demo project click HERE.

To make this Minimap circular, click HERE.

Watch this tutorial step by step on YoutTube HERE.

Tags: , , , , , , , , , ,

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
movierulz Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
movierulz
Guest

These are actually impressive ideas in on the topic of blogging.
You have touched some nice factors here. Any way keep
up wrinting.

F