Get static mesh world location from Unreal Editor
I'm trying to draw some text on the screen in AHUD::DrawText() method.
Now, I think, I have find it how to do it: using
On Unreal Editor, on my map I have a static mesh that I'm using as reference. I get in the editor its Transform -> Location coordinates to use it with
And here is the C++ code:
But this is what I see:
The number 5 is what I draw as text, and the small white vertical rectangle in its left is the cube I selected in the Unreal Editor.
What am I doing wrong? How can I get (or know) the correct World coordinates for the rectangle?
Your issue is more likely to be viewport/DPI scaling rather than the static mesh's location.
There is another version of ProjectWorldLocationToScreen called UWidgetLayoutLibrary::ProjectWorldLocationToWidgetPosition, try that. It accounts for things like viewport/DPI scale//etc which are most likely the cause of your issue.
You'll need the following include:
Although its under UMG, that function doesn't appear to contain any UMG specific logic so should be applicable for any kind of projection.
answered Jul 12 '17 at 04:34 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here