UE4 Tips: Plug and Play Radar

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

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:

addtoradar

RemoveFromRadar:

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.

AddActorComponent

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

radarcomponentblueprint

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):

getradarcenterposition

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)

screencooridnates

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))

GetRadarDotPosition

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:

drawingwholething

  • 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

Creating ShooterTutorial takes a lot of my free time.
Buy Now Button
If you want you can help me out! I will use your donation to buy better assets packs and you will be added to Credits /Backers page as well.

Implementing game is taking time but writing about it is taking much more effort!

28 thoughts on “UE4 Tips: Plug and Play Radar

  1. You rock. If you could do a follow on tutorial that would include a background image for the radar you would really rock.

    And by the way if you continue on this firestorm of tutorial writing the marketplace will become insolvent!

  2. Hi! Really nice tutorial. I used it for my game project but I can’t figure out how to make the radar ignore the players rotation. I am making a top down game and I do not want the radar to rotate with the player.

    Is there an easy way to modify your work to make it happen?

    • Since there is no way to remove a comment I’m just gonna say that I solved it by changing “get actor transform” –> “get actor location” and then translating it to transform in the Get Radar Dot Position.

      I should have played around more before posting, but thanks again for the tutorial. Really awesome work!

  3. I seem to have everything implemented in working, but I’m not sure how to make the actors that use the radarcomponent to update their location on the radar. They update on event begin/end play as was defined in the component. If I move a physics actor with this component, for example, the radar blip will remain at the position that it spawned.

    Thanks for sharing!

  4. Great Tutorial! I got the radar to work but I was just wondering if you could potentially shed some light on how you would expand the distance clamping part of the blueprint to create a circular radar?

  5. Great tutorial, I made a few mistakes in the hurry cause it looked so simple, but very easy to fix and extend upon.

    One issue I have come across though is creating some sort of alpha mask around the radar itself, I have the objects disappear if they reach the edge of the map, but on the bottom and bottom right edges, because of the objects “pivot point” it draws over the radar edge.

    is there some sort of mask i can apply to stop this?

  6. I expanded this into displaying different colors for friendly, enemy or objective stuff. But… there is a problem, sometimes it only displays the initial actor location, and stays there dispite the actor moving around or being dragged (physics object). Any idea how to make the dot follow the actor “no matter what”?

  7. It returns the error of “Error Blueprint Runtime Error: Accessed None trying to read property RadarActor from function: ‘GetRadarDotPosition’ from node: Return Node in graph: GetRadarDotPosition in object: FirstPersonHUD with description: Accessed None trying to read property RadarActor.

    It’s all exactly as you described it except in the Radar Component actor I was not able to use Cast to RadarHud, it does not exist, I used Cast to FirstPersonHUD. I do not know if this part is correct, can you help me?

    • yeah i get the same, i think its to do with the actor array not getting referenced. but probably more to do with the later engine version, this is for 4.9

  8. Hello.

    First of all, thanks for the tutorial. I manage to complete it with first shot ! It’s really awsome and easy to use (could be a Marketplace asset man !), but I was just wondering some things :
    – First of all, would it be possible to convert this to a UMG widget ? In order to get more flexibility for customization…
    – Would it be possible to change the Players’ square indicator to a Arrow-Type ?
    – Would it be possible to add a sort of ‘Visibility field’ on the map (like a gradient cone rotating with camera view ?
    Once again, thanks for your good (Amazing !) work !

  9. In the last image, how are you calling functions without connecting an input? When I try to “Get Radar Dot Position” or “GetRadarCenterPosition” it’s dropping them in as nodes that require an input connection for them to fire whereas in your screen shot you’re dropping them in as if they’re variables but you never told us to store the info as a variable.

  10. In the last image, how are you calling functions without connecting an input? When I try to “GetRadar DotPosition” or “GetRadarCenterPosition” it’s dropping them in as nodes that require an input connection for them to fire whereas in your screen shot you’re dropping them in as if they’re variables but you never told us to store the info as a variable or when you’re calling the function.

  11. Got it working but can’t remove dot after I destroy actor, it is moved off-screen but is still visible. How can I remove the dot completely?
    Good video and very useful so far

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.