Hello Unity fans and welcome back to my game development series. Today, we’re adding a stock-standard feature when it comes to games played on some kind of large map. The player usually needs a way to quickly jump to different areas of interest of the playing environment. It is also very helpful to have an overview of the world, in much less detail, to allow you to orientate yourself, plan strategic moves and keep an eye on important large-scale factors. Many of these mechanics or functionalities are accomplished through the use of a mini-map. Let’s design our mini-map and look at some possible pitfalls in the process.
Music: Rising Moon, Exploration, The Bard's Tale by Random Mind
/ @randommynd
Part0 (Introduction): • [Unity3D Hex Map Game Dev] 0: Introduction...
Part1 (Hexes to Water): • [Unity3D Hex Map Game Dev] 1: Hexes to Water
Part2 (Features and Textures): • [Unity3D Hex Map Game Dev] 2: Features, Te...
Part3 (Units, Visibility): • [Unity3D Hex Map Game Dev] 3: Units, Pathf...
Part4 (Random Maps): • [Unity3D Hex Map Game Dev] 4: Creating Ran...
Part5 (Post Processing): • [Unity3D Hex Map Game Dev] 5: Post Process...
Part6 (Resource Gathering): • [Unity3D Hex Map Game Dev] 6: Automated Re...
Part7 (Spinning Selector): • [Unity3D Hex Map Game Dev] 7: Spinning Obj...
Part8 (Preparing for Resources): • [Unity3D Hex Map Game Dev] 8: Preparing fo...
Part9(How Much Wood?): • [Unity3D Hex Map Game Dev] 9: How Much Woo...
Part10(Dynamic Trees): • [Unity3D Hex Map Game Dev] 10: Dynamic Trees
Part11(Meet The Meeples): • [Unity3D Hex Map Game Dev] 11: Meet The Me...
Part12(Harvesting Wood): • [Unity3D Hex Map Game Dev] 12: Harvesting ...
Part13(Harvesting Stone): • [Unity3D Hex Map Game Dev] 13: Harvesting ...
Part14(Walking Around Wallls): • [Unity3D Hex Map Game Dev] 14: Stop Walkin...
Part15(Multiple Unit Types): • [Unity3D Hex Map Game Dev] 15: Preparing f...
Part16(Manipulate Terrain): • [Unity3D Hex Map Game Dev] 16: Manipulate ...
Part17(ResourceBuilding Upgrades): • [Unity3D Hex Map Game Dev] 17: Resource Bu...
Part18(Camera Fly-through): • [Unity3D Hex Map Game Dev] 18: Camera Fly ...
Part19(Animated UI): • [Unity3D Hex Map Game Dev] 19: Animated Us...
Part20(Automated Farming): • [Unity3D Hex Map Game Dev] 20: Automated R...
Part21(UI Anchors, Buttons, ToolTip): • [Unity3D Hex Map Game Dev] 21: UI Anchors,...
Part22(Linking Graphics, Mechanics, UI): • [Unity3D Hex Map Game Dev] 22: Linking Gra...
Part23(Segmenting Hexes): • [Unity3D Hex Map Game Dev] 23: Segmenting ...
Part24(Smooth Irregular Movement): • [Unity3D Hex Map Game Dev] 24: Smooth Irre...
Part25(Pathfinding on Segments): • [Unity3D Hex Map Game Dev] 25: A* (A-Star)...
Part26(Avoiding Unit Collisions): • [Unity3D Hex Map Game Dev] 26: Avoiding Un...
Part27(Inverse Movement): • [Unity3D Hex Map Game Dev] 27: Inverse Mov...
Part28(New Textures): • [Unity3D Hex Map Game Dev] 28: New Versati...
Part29(Assign Workers): • [Unity3D Hex Map Game Dev] 29: Assign Rand...
Part30(Tasks Fly-through): • [Unity3D Hex Map Game Dev] 30: Automated T...
Part31(Progressive Building Preview): • [Unity3D Hex Map Game Dev] 31: Progressive...
Part32(Automated Task Queues): • [Unity3D Hex Map Game Dev] 32: Automated T...
Part33(Optimal Placement Recursion): • [Unity3D Hex Map Game Dev] 33: Find Optima...
Part34(Progressive Construction): • [Unity3D Hex Map Game Dev] 34: Progressive...
Part35(Meet the Ladies): • [Unity3D Hex Map Game Dev] 35: Meet the La...
Quite often, the mini-map is basically a birds-eye view of the entire map or world, with some points of interest given special importance. It can therefore be tempting to simply place a second camera high above the map looking down at everything below, and just let it render its view unto a panel somewhere in the corner or on some UI overlay level. There are a few problems with this option. Firstly, this can greatly increase the amount of resources spent on rendering every frame. You suddenly have an extra camera that needs to render the entire world, even though some parts of it would be so small that any rendered detail would just be a waste of resources. Having different Level-of-Detail meshes, or LODs, may alleviate some of this, but usually, a different approach is required. Secondly, the scale of certain objects or important points of interest are often exaggerated on the mini-map, since they are more significant in terms of high-level strategies, while other features or details can be totally omitted.
This warrants a different approach. We need some way of mirroring the world map, but in a lot less detail, and with more focus placed on important strategic features. We do need a second camera to provide the birds-eye view for us, but it actually does not even have to see the detailed world.
What we’ll do is create the low-detail meshes of the mini-map in combination with the higher-detail meshes of the terrain. We already have the Grid-chunk prefab that combines all our terrain layers by creating a separate mesh for each layer. My first attempt was simply adding mini-map versions for the appropriate layers. Each chunk of 5x5 hexes consists of one mesh for each of these terrain layers, and they would all be rendered on the main camera. The meshes dedicated to the mini-map are placed on a separate camera layer, so that we can tell the main camera to ignore them, and the mini-map camera to only render that specific mini-map layer. We’ll have a look at the detail a bit later, but let’s go through the high-level idea first.