Hi all, I have been trying to implement a radar system along with a radar grenade into my team’s game. At the moment, we have a radar grenade that can get the coordinates of any enemies that overlap its detection sphere. We just can’t seem to get dots printed to the radar widget when an enemy is detected. I have been banging my head on this one thing for weeks. Relevant blueprint pictures are attached.
Since I eventually want to implement a radar into my game, I decided to give it a shot. I’ve got something sort of working, but it keeps crashing the editor for some reason. I’ll work on it tomorrow and update you with what I’ve come up with.
Alright, I’ve got the math stuff figured out. Here is what it looks like so far. Now I need to figure out how to fix the crashing.
Looking forward to seeing how the widget system compares with this free basic HUD version.
Basically what I’ve got is a giant capsule component in the character Blueprint. On overlap with this capsule, it creates a widget and adds it as a child to an overlay palette inside my main UMG widget. Each widget that is created is mapped to the object that it overlapped with, that way I can keep track of each of the blips.
Then on a tick event, I’m looping through the keys in said map (containing the overlapped actors), plugging their position into an inverse transform, which is then plugged into a Set Render Translation function on the blip widgets.
On end overlap, I’m removing the corresponding blip widget from parent and the key from the map. I think what’s causing the crash is it’s removing the widget and key value while the tick event is looping through the map.
Thanks @franktech for the heads up!
This is really interesting. I’ve been trying to create a radar as a UMG widget for a while and ended up using the HUD class as a solution. I seem to have the functionality figured out without any crashing, but Im stuck using HUD (no native scaling, less flexibility) because I didnt know how to draw sprites to a widget.
Here’s the radar system:
Download Thread: https://forums.unrealengine.com/showthread.php?143814-FREE-Radar-Blueprint-Track-enemies-friends-pickups-and-more!
I would love to combine our solutions and share it with the community if you are willing to help :).
Could you share your code on how you are drawing to canvas on UMG? If I can figure out how to do this, I should be able to convert my radar into UMG. Conversely, check out my solution and see if you can adapt something to your widget.
So I discovered that removing the Keys from the Map is what was causing the crashing. It wouldn’t crash if I only had 3 or 4 Blips, but anything over that would cause it to crash as I moved around and stopped overlapping with some of the actors. Now what I am doing is just removing the Blip widget from parent. If an actor is overlapped with again, it simply creates a new Blip widget and re-maps it to that actor. I’m not sure if the Blip widgets are still persisting in memory.
Here is the main body of code in the character Blueprint:
Function to add/remove Blips:
Function to update Blip position on screen and remove blips:
Thank you @ausernottaken!
I think I have enough to convert my radar to a widget! The key was using Set Render Translation and using Canvas to add children.
Thank you so much for sharing that radar with me. My team and I have decided to use your solution.
I do have a question, though. We have a pause menu for our game, and we are using the “FirstPersonGameMode” blueprint that comes with the engine. When you start the game, you are presented with two options: “Start Game” and “Settings”. When I clicked “start game,” the the game would start, and the menu would disappear.
However, when I implemented your system, the game starts, but the menu stays. Could you help me out here? The first person gamemode screenshot is probably the first thing you wanna check out. The rest of the screen shots are there in case.
I’ts not very clear from your screenshots whats going on. The radar operates using a custom HUD class (specified in the Game Mode) and has no connection with any widgets you are using. To hide the radar, you can use this code below:
Hopefully that helps, otherwise, please post the Blueprint where you click “Start Game” to see whats going on.
Hope this helps!