UE4 UMG Minimap - How To Make an Overview Map

In this post we will see how to setup an overview map, it's fairly similar to making a minimap but with some minor settings, we will also see how to add a marker when we press the left mouse button in the overview map, and remove it with the right mouse button, we will add the marker to the minimap as well.

Link to the Dynamic UMG Minimap

Step 1 - Create the widget


Right click somewhere in the content browser and go to User interface then Widget blueprint, let's name it WidgetOverviewMap, in the palette look for MinimapComponent and add it to the widget. We can anchor it in the middle and set the size to something like 1200 for X and Y. In the settings select your Map Texture and make sure you enter the right Map Length In Texture, the only difference from a regular minimap is the Big Map option, we need to check that.



Don't forget the Big map settings section if you need to tweak that for your game.

Let's add an event that we can call at the start of the game to create our minimap and overview map, my minimap is going to have the name MyMinimap and the overview map is MyOverViewMap, let's also add an event for handling the OnClick event of the Overview map, basically when we click on the overview map we want to get the world location and maybe add a marker or something similar, I'm going to name the event HandleOnClickMap and I'm going to call it just after I finish creating the minimap and overview map.


Before we handle the onClick event let's take care of actually displaying the overview map when M is pressed for example.


Now that we can show/hide the overview map and have the mouse cursor visible and ready to click on the overview map, let's handle the Onclick event. So what we want to do is bind an event to the MiniMapClicked that's triggered by the minimapComponent,  let's get the MinimapComponent from the MyOverviewMap variable and look for bind event to MiniMapClicked, then from the event (Red) let's drag and select Add event so that the event is added automatically with the parameters.


Let's name the event OnClickTrigger and so basically whenever you click on the overview map this event is going to be triggered with informations about what mouse button used, and the actual world location.
Let's use this event to add a marker to the overviewMap and minimap as well. For this we're going to spawn an empty actor as a dummy Actor, you can create an empty actor yourself or we can use one of those empty actors in the SenToRiousMinimap > Minimapcomponent > Actors.
Right click and look for SpawnActorFromClass and select your dummy actor then right click in the return value and select promote to variable and name it Marker, now all you need to do is verify if marker is valid, if it's not you'll need to spawn it and add it to the minimap and overview map, if it is valid you only need to change its location and it will be updated automatically in the minimap. You also want to check what mouse button was used, if it's the right click we can remove the marker by simply destroying the dummy actor, if it's the left mouse button we either spawn the marker if not valid, or change its location if it is.


Finally don't forget to call the SetupTheMinimap in your BeginPlay event or whenever you're ready, if you're trying this in a multiplayer game don't forget to check if the player is locally controlled, or mark the SetupTheMinimap as Run On Owning Client and call it from the server on Event possessed or something similar.

Comments