In this tutorial I will show you guys how to create simple radar for your game.
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
Creating ShooterTutorial takes a lot of my free time.
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!
the image is very small cant see any thing bro
Copy the image link and paste it on your browser. Now, remove everything after .jpg and hit enter.
thanx buddy
It’s awesome that you are making these tutorials, but it would be even better if you could add higher resolution images, so we can follow more easily 🙂
Thanks!
Thanks for feedback! Will do that!
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!
I Only see the center dot and no actors can you help a noob as to what i need to do to see actors too. Many thx
It’s hard to tell what isn’t working for you – can you show me your blueprints. Have you added components to actors that should be visible on radar?
great tut
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!
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!
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?
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?
in the last blueprint,how exactly you connected the event recieve draw HUD and screen size it was a vector2d?
Right click on the input, and split pin
right click on the input and click split pin
Entered all of the blueprints, add the components to my 3rd person character, and my AI, used the hud as my gamemode hud, and nothing displayed on the screen.
Can i put this hud in a umg widget?
Excellent!
Is there a way to put it in a widget?
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”?
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
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 !
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.
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.
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
If you destroy an actor that is output to radar, you will get an error message. Is there any way to solve this?