For all Unity developers and developers-to-be, both beginners and professionals!

Report article RSS Feed How to make a minimap

How to make a simple minimap. Based on Rman's script and tips. :-)

Posted by feillyne on Oct 17th, 2010
Basic Other.

After starting your Unity project:
1. Select GameObject -> Create Other -> Camera, rename it as you like it
2. Select Assets -> Create -> JavaScript, rename it to "OrbitCam" or something similar ("MinimapScript\", etc.), edit it

3. Paste the following code:

javascript code:
var target : Transform;
var damping = 6.0;
var smooth = true;

function LateUpdate () {
  if (target) {
    if (smooth)
      // Look at and dampen the rotation
      var rotation = Quaternion.LookRotation(target.position - transform.position);
      transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
      // Just lookat
    transform.position.y = target.position.y + 90;
    transform.position.x = target.position.x;
    transform.position.z = target.position.z;

function Start () {
  // Make the rigid body not change rotation
    if (rigidbody)
    rigidbody.freezeRotation = true;

4. Click the minimap camera you created earlier, then without clicking the script, drag the script onto the camera name
5. Still having the minimap camera on, drag the target of the minimap (the character, car, whatever) onto the field Target

All is set. Remember that the Depth of the minimap camera should be above the Depth value of the Main Camera, or the minimap itself will be hidden behind the Main Camera view! Very important!

An example of minimap camera properties set:

Minimap camera

Projection property can be set as either Perspective or Othographic, with Field of View also customised to your needs.

Normalized View Port Rect properties can be set as following:
X: 0.04 (0.54 for the second minimap if you use the splitscreen multiplayer))
Y: 0.04 (0.54 for the second minimap)
X and Y properties specify the position of the minimap on the screen.

W: 0.2
H: 0.2

W (width) and H (height) properties specify the size of the minimap. 0.2 means 20%. You can set them as you wish.

And that's pretty everything you need to do to get a simple minimap. Remember it's a method very little optimised - better would be creating minimap itself (using a texture).

The credit for the script (OrbitCam.js) and the tips goes to Rman, see his Planet 4 game site:

Post comment Comments
Salynrad May 17 2011, 10:29am says:

This is what I've searched for a long time, thank you for uploading.

+2 votes     reply to comment
LuisVilbro Sep 10 2012, 2:36pm says:

Amazing tutorial, it helped me alot. Thank you.

+1 vote     reply to comment
NakorTBR Dec 7 2012, 12:44pm says:

Yeah this is great for certain games. Unfortunately I can't really do this as it would increase my draw calls enormously.

+1 vote     reply to comment
Guest Jun 19 2014, 5:00am says:

This comment is currently awaiting admin approval, join now to view.

Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Oct 31, 2010
Open to all members
Send Message
Members Only
Join this group
Group Watch
Track this group
Report Abuse
Report article
Related Games
CarEdu Single & Multiplayer Racing
Related Engines
Unity Commercial Released May 30, 2005
Related Groups
Indie Devs
Indie Devs Hobbies & Interests group with 1,176 members
Unity devs
Unity devs Hobbies & Interests group with 1,297 members