Need some help figuring out a Widget that is placed in my environment.

Hello !

I must preface this question by saying that I’m quite new with UE5.

My problem is as follows:

I am trying to make a Sonar blueprint that will be set in the game world. A static object so to speak. The player will have to move their characters to that console and interact with buttons placed on the console, but their screens will never snap to the console’s screen itself.

In that Sonar BP there is a Widget dictating where, in a 1000x1000 pixel grid, a signal will spawn on a Canvas Panel.

The signals are another widget that’s basically just an image with a text slot to add/edit coordinates.

I am adding this new “WBC_Signal” widget inside a Canvas Panel slot that is empty, but I can’t seem to get anything to show on the widget itself.

I tried using a few vector data from my Signal objects that I placed in my map but I can’t seem to figure out if my problem lies with my understanding of the concept of a widget or with my maths to get the World position vector from my objects into a 2D vector 1000x1000 pixel grid where the origin is supposed to be in the middle (at 500x, 500y).

Any ideas where I should start looking ?

Hey @mantricore

May be I need to see the function you use to calculate the “Signal Location”, but things I can tell you:

  • Make sure the size of your signal widget is exactly what you expect it to be, no stretching or relative to anything else. It should preserve aspect ratio with the “Console”'s widget scale.

  • Depending on how you set the anchors for the Signal Widget, the calculations for its location will change. If you want to do it based on the Canvas center of its parent, assign (x: 0.5, y: 0.5) as the anchor values.

  • Also, in case I understood correctly, the position shouldn’t be calculated based on 3D world space, it should be only relative to the Console’s Widget.

Thanks for the quick response @GRIM_Warlock !

  • Concerning your first point, I’ve checked the signal widget that gets called by the Sonar widget and it doesn’t seem to be stretched or relative to any other object as far as I can see.

  • The anchor on the Sonar widget is set to the middle (x:0.5 , y:0.5) just as you suggested, but should the Signal widget be the same ? Will its components inherit the Sonar’s anchor values or will it keep it’s own?

  • As for the last point, It’s a bit of both. These signals are actors BPs that have the tag “Signal” assigned to them. Once they’re placed in the world and their collision overlaps with the detector’s capsule collision, it adds each of them to an array. That array is then called each “X” seconds and it calls the function to update the Sonar widget, which then adds the signals to itself.

The order of operations is as follows:
BP_Sonar catch signal → Add signal to array → Gives array to WB_Sonar (The “parent” widget) → ForEach signals get info (Picture Below) → Translates that info to WB_Sonar’s scale grid of 1000x1000 pixels → Adds a WBC_Signal (The “child” widget) on the Canvas at those coordinates

Question2

“Target” are those actors in the Array
“Signal Direction Vector” is the Actor’s location vector - Detector’s location vector
“Current Detector Location” is the Detector’s location vector
“Signal index” is the Signal’s index inside the Array
“Detector Forward Vector” is a “Get world Rotation” → “Get forward vector” of the Detector
“DEBUG:Signal Location” is simply a “Get actor location” of the signal inside the array

I tried lots of different ways to get this to work, many of those values might be redundant.

I hope my explanations weren’t too chaotic, my brain’s mush after being stuck on that for so much time.

See if this clarifies things a bit:

  • this is the sonar widget, all default settings:

Added a border :point_up_2: so we can see where the widget is.

image

We’re going to send the widget some ready :point_up_2: 2d coords.

You can use another method of placing stuff in the canvas, obtaining coordinates will be similar. Here I am painting with brushes.

  • the player adds the widget:

You can run it on Tick, or every X seconds with a Timer (and perhaps mask the infrequent updates with fade in/out animations as pings materialise):

  • the calculations are done like so:

In short: we MapRange translate relative vector into a 2d screen coordinate. It’s a glorified minimap.


Project link to mess around with it:

Hope it helps!

Very sorry about the delay in my response, I was unable to test this new solution for a good while.

It worked ! Although I realized that my “problem” was not only my math (Which was almost correct, the “Map range clamped” node is a life-saver) but also a slight error in object type while I was describing my issue.
I am working with a widget component inside a BP. While the widget itself was good, the component was all over the place as well… I couldn’t get anything on it because the draw size was set to 100.

But thanks to you all, I managed to get a core component of my project prototyped!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.