Project World Location to Widget Position seems incorrect.

Hello,

Currently, I’m trying to use the Project World Location to Widget Position node along with Set Render Translation to make a widget appear wherever my pawn is on screen like so:

With this setup my widget appears translated but with a considerable offset. A print of the value that GetActorLocation returns seems accurate but the output of the widget position node doesn’t match. For some reason it’s including a large offset in the conversion. I’d like to correct this offset.

Any advice would be appreciated.

Thanks.

This is an incredibly delayed answer but hopefully someone else stumbles upon this and finds it useful.

For some reason I found getting the screen resolution, divided by 2, then adding the size of the icon/image works.
In my case, this is for a ‘Z lock-on’ and so I added a little more Y offset so the lock-on indicator is on the enemy torso.

I am positive there is a better way to do it, but this worked for me.

2 Likes

Thanks for chiming in, Dave.

If anyone else sees this post, please share your techniques!

Thanks for the blueprint code it really helped me out!

Do the screen res x and screen res y variables correspond to the actual screen resolution or to the size of the viewport?

Since this was originally posted, “Project World Location to Widget Position” now has an additional bool node called “Player Viewport Relative”, this probably wants to be ticked, especially in split screen.

As for aligning based taking into account the size of the widget, it depends how it’s setup. I’ve found the best results come from having the widget without ANY canvas, lets just say an image only. And then you’ll want to subtract that image’s “Get Desired Size” / 2. And for me that does the trick when I input it into “Set Position in Viewport” (different from the “Set Position” originally posted since I ticked that new bool).