Can't put widet to correct screen location

hi devs i am trying to make widget that indicates the distance to certain player and will be on top of each player, the screen location isn’t working correct ? any thoughts why ? widget always pops up on upper left corner , here is a code and widget itself


I’m curious about this too, so I will tell you how I do it and then hopefully someone with more experience can also add some input.

When I make a HUD widget the first thing I do is drag in a canvas. Then in the upper right corner, I set screen size to my resolution(don’t know if this matters). The canvas will take up the whole screen, and I put my widget stuff where it should go. After it is all in place, I change the screen size to “desired on screen”. This makes everything work right for me, but I don’t know if there is a better method.

The code you posted in the SS would only spawn at a location and not follow a player around. You might have to have the add to viewport node before the set position in viewport node too.

Use an overlay or a canvas panel as the root widget in the hierarchy.

Then you can position the text where you prefer.

I might be wrong about how exactly this works, but the result is predictable enough that you can call it a “rule”:
The topmost widget anchors to the screen upper left corner, and fills the screen.

Thats what your text widget is doing.

Using an overlay or canvas panel is like adding a big invisible canvas that you can use as a means to position other widgets on. A canvas panel allows more direct sizing manipulation, whereas an overlay allows you to place widgets proportionally.

I’ve read from some UI gurus that overlay is generally more performant than canvas panel, so I tend to opt for that unless I can’t do what I want with it.

edit - also, is this screen space widget?

The resolution setting is just for preview purposes in the widget editor. It doesn’t effect anything about the actual widget itself.

Desired On Screen will show how much room the widget “desires” to use. For instance, if you have an image in a size box and set the size box to 128x128, then the desired size would be 128x128.