UMG Radar Setup

In this page we will see how to easily setup and add the radar to your viewport, then add AI characters to track.

1- Create a new widget blueprint

You can create your own widget blueprint or use the UMGRadar already created in the main folder, to create your own right click in your content browser and select User interface then widget blueprint

2- Adding the Radar component

I'm going to name it UMGRadar, open up the widget you just created, in the search palette look for UMGRadar Widget component and add it to widget

3- Customizing the settings

Select the Radar component we jsut added and in the details panel modify all the properties you like to modify. Don't forget to specify the map width if you're not sure what that is just give it something big to be safe (third person template is about roughly 7000 in width)

4- Adding the widget blueprint to the viewport

Let's add this widget to the viewport, I'm going to do this in the begin play of the character. I named it UMGRadar so that's what I'm going to add, I'm also going to save it in a variable so that I can access the radar component anytime. After you add the widget to the viewport make sure you call RadarUpdate and give it the owner of the Radar which is our character in this case.

 5- Adding targets to track

Let's add something to the radar, I have a couple AI characters in my level the name of their class is T_FriendlyAI, let's use the GetAllActorsOfClass to get all of them. Using the variable I stored the umg in I can get the Radar component and call AddActor or AddActors for multiple targets at once, the function gives us the ability to customize the look of the target we're about to add and track, if you want to persistently track these actors make sure you  check Persistent and select a off screen texture like an arrow or something like that.

6- Handle clicking on the radar and add a marker

Let's handle the OnRadarclick event to get the world location whenever we click on the radar, I'm going to use this event to display a marker in my radar, and when I right click I'm going to ask to remove the marker.

Comments