UMG world to screen space vs resolution.
I've tried this in both 4.6.1 using the playercontroller worldposition to sceenspace as well as 4.7 with the screen space option in a blueprint with a widget component. If the screen resolution (r.setres XxY) doesnt match the window size, the widget position will be incorrect. The effect can only be seen in fullscreen since r.setres in windowed resizes the viewport. Here is the result, first picture is 1280x720 windowed second is 1280x720 fullscreen on a 2560x1440 native res panel.
After looking over your issue I believe I have a workaround for you. Right now there is an issue with widget assuming that the screen size is 1920x1080 and so it reads the resolution give to it as though it were being used on a viewport of 1920x1080. I have a formula that will allow you to get an accurate position. I hope that this helps.
Here is the formula that can be used to set the position of your widgets. PLEASE NOTE: this requires the original position of the widget to be 0,0 and it must be anchored to the top left corner of the screen. The rest of the notes are listed in the picture. This was all done in the event graph of the widget.
Here is an example of what it looks like when I had finished. My widget size in this example is 70 by 70.
How the math works:
1920 x 1080 is divided by the actual view port size (X and Y receptively). This then give a ratio of what the widget thinks the screen size is versus what the actual screen size is. (Example: Let's say the viewport size is actually 960x540. Which means 1920/960 = 2 and 1080/540 = 2. This makes the ratio for your X is 2 and your Y is 2. this means for every point of resolution you set your widget by on the actual size of the screen it will think that it has moved 2.) Now that you have your ratio you are going to multiply that but the screen position you would like to have the widget displayed at. (Using the same example: Lets say you want the widget at 100 by 100 this will need to be multiplied but the ratio (2 in this example) make it 100*2 = 200 and 100*2 = 200. The 100 is the actual position and the 200 is what the widget thinks it's at. This will fool it in to placing it in the right spot.) After this you will want to set he position of the widget using the anchor points. I have found this to be the most accurate way to set the positions using this method. To do this you will need to understand that anchor positions go from 0,0 to 1,1 in respect to X and Y. To get this you will need to divide the current formulated position of the widget by the maximum viewport size (this will give you a percentage of sorts (mean that 1 in this case means 100% of the screen size and 0 being well 0%) and allow you to set the position of the anchor).
Make it a great day
answered Feb 20 '15 at 08:02 PM
Rudy Q ♦♦ STAFF
I had a similar problem while trying to get a crosshair system to work, and I found an excellent solution in a forum post.
Long story short, multiply the screen location coordinates by the inverse of the viewport scale.
(Yes, this question is over 2 years old, but I hope this answer helps someone searching around.)
answered May 05 '17 at 05:24 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here