In this tutorial I will show you guys how to create simple radar for your game.

<strong>This Tutorial has been created using Unreal Engine 4.9.2</strong> Make sure you are working on the same version of the engine. 1 2 < strong > This Tutorial has been created using Unreal Engine 4.9.2 < / strong > Make sure you are working on the same version of the engine .

Basics

If you are looking for more advanced radar / minimap there is one already in marketplace.

I will show you the basics which you can extend later. This will be plug and play version. Basically the main issue with radars it to convert radar location space to player location space. I will show you how to do it just with one node.

Preparation

Create new GameMode named. It will be used to just test the HUD. Next create new HUD class and connect the HUD class in GameMode. Make sure your map uses this game mode.

Radar Component

I will use actor component for those actors that can be visible in radar. Thanks to this you can easily decide which actors should be shown.

In your HUD class create new variable:

RadarActors (Actor Reference, Array)

And two functions.

AddToRadar:

RemoveFromRadar:

Thanks to this we won’t be searching for actors that should be rendered on Radar. Instead we will register them in this array. Now let’s move to component.

Create new Actor Component named RadarComponent.

Add new End Play event and use Begin Play as here:

So basically when actor that have this component will be spawned it will be added to RadarActors array.

Radar Drawing

Again open your HUD class and add those variables:

ScreenSize (Vector2D),

ObjectDistanceScale (float, default: 25)

RadarStartLocation (Vector2D, default: 0,1 / 0,2 )

RadarSize (float, default: 100),

And add functions below.

GetRadarCenterPosition (pure, outputs: X (float) , Y(float):

This will get 2d start coordinates to be draw by hud – it will be location for player dot on the radar as well. Why I’m multiplying screen size by radar start location? To get relative locations on screen without hard coded variables like (X:150, Y:220)

So if you want to place your radar in center of the screen (without thinking about what’s the resolution of the screen) just change RadarStartLocation to 0,5 / 0,5.

Now let’s move to next and most important function.

GetRadarDotPosition (pure, input: Actor Reference, output: X (float), Y (Float))

This is whole math for getting dot position on screen space! I remember UE3 times where you need to do sinus cosinus stuff and lot of math to get this working. Now in UE4 this is all what you need to do to. Everything else is under the hood.

Now we need to finally draw something on screen 🙂

Create new Event Receive Draw HUD:

This will draw dot (which is Draw Rect) for all actors that were registered,

Draw player dot to the center,

Draw simple rectangle to see where is radar,

And that’s it!

Final Result