Hey Guys! I figured I would document my process for creating a Mini Map for the Game Tutorial. I've made this kind of map in bare Unity before, but making it work in ORK required some changes to the process! Special thanks to Shadow_Fire for pointing me to the right node. Here we go!

Step One: Setting up in the Hierarchy

1a) There are a couple things you need to create ahead of time so you can put them together. In the project folder, under Assets=>Materials folder, you want to create a 'Custom Render Texture'. Rename it to "mapDisplayTexture".

1b) While you are in the Materials folder, you can also create a new Material, set the shader to 'Unlit/color' and the Main Color to a nice bright blue. Name the Material "mapPlayerMat".

1c) Next, in your Town Scene, create an empty Game Object and name it MapCam. Place it at ground level somewhere around the town entrance.

1d) Add a New C# Script component to the Game Object and name it "camera_ControllerScript". Doubleclick the script to open in MonoDevelop (Visual Studio).

This is your code:
//declare variables here
private Quaternion setRotation;

// Use this for initialization
void Start () {
setRotation = transform.rotation;

// Update is called once per frame
void LateUpdate () {
transform.rotation = setRotation;
The variable of Quaternion type stores the game object's current rotation at game start, and then every frame the game object's rotation is re-set to that initial rotation. Which means when the MapCam is attached to a player, the player can turn every which way, but the map will still be oriented with forward as 'north'.

1e) Create a Camera as a child of MapCam. The camera settings are as follows.
Position (x0,y20,z0),
Rotation (x90,y0,z0)
Clear Flags = Solid Color,
Background = black,
Culling Mask = Everything (for now).
Projection = Orthographic,
Size = 10.
Target Texture, (this one is important) is set to the "mapDisplayTexture". This means that, instead of rendering to a screen every frame, it saves the render to the texture file, and overwrites it every frame, aka. in real time.

You can play with the y position of the camera to make sure the clip is above your trees and buildings, and the orthographic size until it is as far or close as you would like for your map view.

1f) Set the Transforms of your MapCam to Position (0,0,0) Rotation (0,0,0) Scale (1,1,1) and then drag the Game Object into your prefabs folder.

1g) Create a Sphere with a radius of 1.5 or 2. Name it "mapMarkerPlayer" and drag the mapPlayerMat material onto it to turn it bright blue. With the sphere selected, click on the Layer dropdown under its name in the Inspector and go down to 'Add Layer'. Name the new layer "mapMarker" and assign the sphere to that Layer. Now, only cameras and lights set to interact with the 'mapMaker' layer can see or effect the sphere. It will be invisible to cameras where this layer is not checked in the Culling Mask dropdown in camera settings.

Zero out the transforms by rightclicking the cogwheel icon at the far right of the Transform component in the Inspector and selecting reset. Drag mapMarkerPlayer into Prefabs.

Step Two: Menu Framework

2a) Open Ork Framework and move to Base/Control = Input Keys. Create a new key, name it "Map" and set the input origin to Key Code and your Positive and Negative fields to M (you can change this to fit your own game's control schema, M is just far enough away from WASD to avoid an accidental hit)

2b) Move to Menus => GUI Boxes and copy Menu Small. Change its name to Map. Change to Content Box Settings to (x1025,y10) (w250,h250) anchor Upper Right. Deselect Show Box.

2c) Menus => HUDs. Add and name it MapHUD, using the GUI Box 'Map".
HUD Settings:
Hud Type = 'Information'
Use Toggle Key = Selected
Start Toggle State = Selected
Toggle Key = 'Map'

Information Settings:
Auto Update = Selected. This makes sure the map refreshes every frame.

Display Conditions:
Ignore all the way down to Battle Types, which is No. Menu Screens = No.

Image Settings:
Here's where we put that lovely texture we made to work. Click the Add Foreground Image button. Set Image Bounds to (w250,h250) and Use Image to Selected. Click the select button on the review window and select your mapDisplayTexture (or just drag it from the project list). Scale Mode can be set to "Scale To Fit" or "Scale And Crop" There should not be too much distortion here.

Step Three: Adding to the Player

You can, of course, just add the 'MapCam' and 'mapMarkerPlayer' to your player character prefab manually, but if you plan to switch which character might be player controlled, the following should be more elegant.

3a) In ORK Framework =>Events, create a New Game Event. On the Event Settings Node: Add an Event Actor set to Type = Player. Add two prefabs.
Prefab 0 = MapCam.
Prefab 1 = mapMarkerPlayer.

Add a Spawn Prefab Node (add => Game Object => Prefab) and set:
Prefab = 'Prefab 0'
Target Object:
Object = Actor
Actor = Player
Use Rotation = selected
Mount = selected

Copy this node and link it into the last one, and change the following
Prefab = Prefab 1
Offset (x0,y2,z0)

Save this event as mountMapCamToPlayer.

3b) Make a New Game Event. In Event Settings:
Use Main Camera = Selected
Add Actor
Actor 0: Type = Camera

Now add a Change Camera Options Node (Add => Game Object => Camera) {Thanks Shadow_Fire!}

Change Culling Mask = selected
Culling mask dropdown, if you click on the mapMarker layer, the checkmark next to it should disappear, meaning the camera will no longer see things on that layer.

Save this Event as "cameraMaskNoMaps"

3c) Navigate to World => Global Events. Create a new Event and name it "Main Camera Settings". Set the Event Asset to 'cameraMaskNoMaps' and then for event Type select Scene. The other settings are fine, but you can fuss with when in a scene the event will run. I left it to "All"

3d) Create a second new Global Event and name it "MapCameraSetup". Set the Event Asset to 'mountMapCamToPlayer' and Event Type to Scene. This way the player will not lose their map when moving to a different zone.

Step Four: Differentiating the MiniMap

As it stands, the current Minimap shows exactly where the player is, from above, in the game world as it exists. You've succeeded! We have a map! But there's more we can to to change the visual appearance of the map

To make things more classical, you could add a Quad to each scene, under the ground terrain but exactly the same size, with a color and set to the mapMarker layer. Then wherever there is an object or terrain feature the player cannot walk through, add a Masking shape (quads are low poly) in black to define where the player cannot go. Changing your MapCam camera so the Culling Mask is set to only the mapMarker layer means you control what the map sees. Setting the Main Camera to never see the Mapmaker Layer means you don't have a bunch of blue spheres walking around.

This is also a away to create "secret" passages ala classic FF minimap. Just mask off an area that people can in fact move through so it's not obvious from the map view. You can add Masking shapes by hand, or attach them to building prefabs and the like, along with any door indicators you want the map to have. NPCs can be tagged with their own colored spheres (red for enemies, green for allies, etc) or you can mark them with icons to indicate quests or allegiances.

A slightly more sophisticated Mini Map that is actually easier in some ways to set up, is to take an orthographic screenshot of your finished scene from above, and take it into a graphics program to then draw a map over it, allowing you to define houses and staircases and trees artistically rather than just black masking, and putting that on the ground level quad. The player can still only go where the player can go in the scene, but the map has more character in light with whatever your game's visual style is.

Once you have a scene set up with the mapMarker layer, you can also create a Big Map Menu and a camera that is pulled back to show the whole zone.
Post edited by gamingislove on
  • Nice one, thanks!

    Wrapped your code with the code tag for better visuals :)
    If you're enjoying my products, free updates and support, please consider supporting me on patreon.com!
  • Thanks for the awesome tutorial!
    Always glad to see someone doing tutorials for the community.
  • @gamingislove Thank you for the tag! I forgot to add it as I was writing. I'll remember in the future.

    @Shadow_Fire Thank you :) I love making tutorials, so there will probably be more. It's a great way to document my own process, and save others from having to completely reinvent the wheel. There are some other really great ones here!
  • That's good to hear!
    Will look forward to more tutorials from you :)
  • Will def look into this tutorial after xmas, thank so much
Sign In or Register to comment.