Trying to picture this but I cannot visualize. You want the on-screen coverage of a thing to always be the same size independent of the screen-res? eg: this thing always takes up x% of the screen, period?
how are you setting the scale? it sounds like thats the problem. i bleieve its called “Set Relative Scale 3D” and you need the mesh component to be the target
You can use the basic projection relationship that is 1/z no? (Z being distance from view)
If you don’t want to use that calculation, or shaders like mentioned above, you can refer to how the editor code is used to display 2D sprites or 3D widgets. That should give you enough information to know how to go back/forth between world and view to determine the scaling. Two example functions you can look at:
class FDisplayClusterLightCardEditorViewportClient : public FEditorViewportClient
FDisplayClusterLightCardEditorWidget::GetLengthScreenScalar
FDisplayClusterLightCardEditorWidget::GetSizeScreenScalar
Most EditorViewportClient subclasses deal with the world-screen transformations to render custom things.
The example code in the functions above, for example this one, deals with DPI, screen percentages, resolution etc. Do you need Blueprint-code specifically?
This is what you want right? The trick is that you need to determine what dimension of your viewport is what your object should relate to. You need to pick vertical, horizontal, or diagonal size. See attached video for result.
p.s. the logic was put together just to get it working, it’s not perfect, optimized or mathematically great d.s.
@Danny Using the GetViewportSize from the PlayerController and not the node with the same name from WidgetLayoutLibrary indeed solves the problem, Jesus. Thanks a lot!