Convert World Location to Screen Location bug ?

Hello everyone,

In my third person shooter, I 'd like to display a dynamic crossair. My problem is that it is not displayed at the right location, there seems to be some constant offset between where the real location and where it is actually displayed. The node Convert World Location to Screen Location seems to be buggy… Is it a known issue?

I work with UE4.6.

Thanks !

Since you’re talking about a constant offset, could it be that the crosshair’s anchor point is placed at the screen location, instead of the center? Perhaps setting the anchor point to the image’s center makes a difference:
alignment.png

If thats not the case, could you provide a screenshot of how it looks?

Here’s a screenshot.

In 4.7, the same nodes work and my dynamic crossair looks good. Unfortunately, I can’t upgrade to 4.7 …

Ah, it doesn’t seem to be the crosshair image’s anchor then. I’m afraid I can’t think of anything else right now.

Are you running the game in Fullscreen? The Projection doesn’t seem to factor in the current windows size right now. If you go Fullscreen, you might see it move location.

Hey, I have the same problem. I have some UMG widgets that will go left and up. I think this started once I launched my game on Android. There’s a thread about this on the answer hub but I wasn’t able to find the file they were talking about:

I had a similar problem just now and found my solution somewhere else on this forum. Posting here because I remembered this thread.

Stuckbug mentioned here:

Setting the resolution scale to 100% solved the issue for me:
reso_scale.png

Maybe this works for you guys as well.

ConvertWorldLocationToScreenLocation predates UMG, it’s only designed to give you correct screen locations if you’re using it for screen related things that map directly to the game’s resolution, like AHUD/Canvas.

UMG/Slate do not exist in the same 2D unit space as the rest of the game. The game’s resolution scale is one source of that difference, another is DPI scale. If a DPI scale has been applied, you still need to transform that “Screen Location” which is in Resolution Scaled, and non-DPI space, into the space of widgets if you plan to use it with UMG. There’s a couple of utility functions that might be in 4.6, UWidgetLayoutLibrary::GetViewportScale, which if you applied the inverse of, after applying the inverse resolution quality, you’d arrive at the proper position for UMG for fullscreen UI.

If you’d like to grab from GitHub, I’ve added a utility for 4.8 to make this task easier, it’s UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition.

That sounds great Nick! Would you say this is the intended way to position widgets over actors?

I know the above explanation is better, but if anyone reading this don’t feel like grabbing 4.8 from GitHub, you can just multiply the output “Screen Location” by viewportscale to the power of negative 1, like so:

153a02ed525e09d55ea5edf1088389cefed67e0a.jpeg

I am not sure whether this has other consequences further down the line, but so far it seems to work for me.

6 Likes

That worked perfectly for me, mrzapp!!! Thanks!

This worked for me perfectly. Thanks for your solution.

Cheers.

1 Like

Thanks mrzapp! Works great and helped me out a lot!

My god!!! This helped me alot on my multiplayer splitscreen game!!!

This is exacly what i needed, Thank you!

Old post, but still comes up in searches for this issues
There is a different function that takes scaling into consideration: Project World Location to Widget Position](Project World Location to Widget Position | Unreal Engine Documentation)

6 Likes

indeed it does! thanks for posting!