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?
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:
If thats not the case, could you provide a screenshot of how it looks?
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:
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.
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:
I am not sure whether this has other consequences further down the line, but so far it seems to work for me.