How to align widget element to screen space?

Hi,


I have following widget. I am getting a instance of a enemy and I would like to move the portion of the umg to the position of the enemy in the world but to screen space.

Unfortunately, I cant seem to align it. I have tried dividing by screenwidth/2 and everything but it always is off and weirdly positioned. I also cannot make sense whne moving it around the canvas. It says 1280x720 but if I move the debug box actually to that location in the widget, its way out of the canvas zone too.

anyway, this is how i am converting to screen space:

and this is the result (note that the capsule is supposed to be the enemy where it should overlay):

(i am using set render translation to move the entire group)

You can use Widget Components to display widgets in 3D view either in World Space or Screen Space

Add a Widget Component to your Enemy Blueprint, Set Draw Space to Screen and set Widget Class to the widget you want to display.

Would be cool to know how one could align individual elements within a widget, this should ideally be moved between enemies and would be great if i can reuse one and move it but I guess trying out the widgets in the bps is an option too.
Would need refactoring on my end tho

Well, you could create a separate actor with just the widget component, then move that actor between the enemies.

I think (I’m not sure) it’s due to the Anchors being centered, try resetting the Anchors to top left.

Or it’s possibly because you’re using render translation instead of SlotAsCanvasSlot → SetPosition.

Just tried this, seems to work.

image

1 Like

Thanks for the help so far brother, will try tomorrow and let you know :slight_smile:

1 Like

hi there, your solution works in my end. It seems the main issue was that I had set the anchor in the middle of the screen. Once I had put the anchor to the top left it works. I am wondering though what calculations I would need to do to get the correct position once I put an anchor anywhere. Set the difference of the positions?
Anyway, thank you for your help Arjun!

1 Like

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