# UMG world to screen space vs resolution.

**URL:** <https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379>\
**Category:** UI\
**Tags:** screen-resolution, unreal-engine, bug-report, Blueprint, question, UMG\
**Created:** [February 19, 2015, 12:07am UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379 "2015-02-19T00:07:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![OpticalShadows](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OpticalShadows](https://forums.unrealengine.com/u/OpticalShadows)\
**Post date:** [February 19, 2015, 12:07am UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/1 "2015-02-19T00:07:29Z")

</div>

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.

 ![30407-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/0/5a0f8b19e2d882c5daca053b1afab24b3b2d8b7d.jpeg)

 ![30408-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/a/8ba6c3cd5f0e50d1c485994423c525d6a8c01dc6.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [February 20, 2015, 8:02pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/2 "2015-02-20T20:02:11Z")

</div>

Hello ,

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.

 ![30584-worldtoscreenhelp2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/d/8/ad83de65da0031d6e95e81d7f5c3f5c361438cd4.png)

Here is an example of what it looks like when I had finished. My widget size in this example is 70 by 70.

 ![30586-worldtoscreenhelp.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/3/0330d37c75f1256d329d29046a545697c799b8c5.jpeg)

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

---

<div class="post-metadata">

**Author:** ![OpticalShadows](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OpticalShadows](https://forums.unrealengine.com/u/OpticalShadows)\
**Post date:** [February 20, 2015, 10:00pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/3 "2015-02-20T22:00:01Z")

</div>

Thanks for the reply! I’m not sure if something isn’t working with my editor because get viewport size doesn’t return the resolution of the screen but the size of the viewport. For example if you try running in any play mode (PIE, new window, standalone) and even if its in windowed mode, if you set either r.screenPercentage 50 or if in fullscreen r.setres (something other than native) it will be offset incorrectly. I my case I have the return of getViewportSize printing to screen for debugging and it doesnt change when setting those console variables.

---

<div class="post-metadata">

**Author:** ![OpticalShadows](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OpticalShadows](https://forums.unrealengine.com/u/OpticalShadows)\
**Post date:** [February 20, 2015, 10:27pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/4 "2015-02-20T22:27:14Z")

</div>

I also want to point out that I built the same setup shown in your example and it only positions the widget correctly if the Viewport is 1920x1080.  
Here is my blueprint: My image is 100x100

 ![30593-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/b/2bb907e8ca56c3c97b576c734fb7b84ee36ce5d7.jpeg)

I would also like to add that before, I had the widget not have a canvas panel as the root but instead used SetPositionInViewport with the result of worldPositionToScreen. This worked with all resolutions, but it would break if the rendering resolution did not match the size of the window.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [February 23, 2015, 3:35pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/5 "2015-02-23T15:35:39Z")

</div>

Hello ,

I see that you are using the Get viewport size from the player controller. This returns the size of the HUD canvas. Are you making any alterations to the size of the HUD canvas? The reason I as is because when I change the screen resolution I am having no issues other than the image offset being a little off. But I compensated for this by simply dividing the half size of the widget by the screen ratio.

Change:

 ![30812-worldtoscreenhelp3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/0/6a042f72ad5fbb2ab13429e3db28ef71a976e225.png)

Here is my Designer tab in case there is any confusion.

 ![30814-worldtoscreenhelp4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/8/71858264b663bdc04405f30568f37f37c440c8e8.png)

---

<div class="post-metadata">

**Author:** ![OpticalShadows](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OpticalShadows](https://forums.unrealengine.com/u/OpticalShadows)\
**Post date:** [February 23, 2015, 4:58pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/6 "2015-02-23T16:58:37Z")

</div>

Thank you for continuing dedication to this problem though it still doesn’t seem to be working for me. I took a video of the problem I’m trying to describe as well as you can see my blueprint below. The problem seems to be that it is placing the widget based on the rendering resolution rather than the viewport size. I cant find any way to read the rendering resolution. I event tried to go C++ with GEngine-\>UserSettings-\>GetResolution() I think (I cant remember the exact code I tried).

 ![30820-capture1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/a/8/9a8a08863a3e6c05d6bfe8d4fb76f5f8d3554eb4.jpeg)

 ![30831-capture2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/3/3a3ad66f90fcfd2b32efba9d4924edee7175f0b7.jpeg)

Here is the video I took: [- YouTube](https://www.youtube.com/watch?v=RYAYm7ON7-U)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [February 23, 2015, 7:36pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/7 "2015-02-23T19:36:01Z")

</div>

Hello ,

I was able to reproduce this issue. I realized the issue only happens in fullscreen. There is a workaround. Instead of manually putting in the console commands I would suggest having the user select from a pre-made list and then use the “Execute console command” node to set the resolution. This will give you the benefit of knowing what resolution will be applied. You could then set the “Make vector 2D” node to what ever resolution is being applied.

Example:

 ![30856-worldtoscreenhelp5.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/6/bb678d610818e9522b2fc8f932fc7c4ee07b5344.png)

 ![30858-worldtoscreenhelp6.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/b/85b98ec7b5172291e7c4c8d42be752eabff48846.png)

---

<div class="post-metadata">

**Author:** ![OpticalShadows](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OpticalShadows](https://forums.unrealengine.com/u/OpticalShadows)\
**Post date:** [February 23, 2015, 9:51pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/8 "2015-02-23T21:51:14Z")

</div>

I’ve thought of that solution. To be honest it’s not the biggest problem and it’s rather a special edge case scenario. Do you know if there is any way of getting the current 3D resolution? A C++ solution is fine. The GEngine-\>GameUserSettings-\>GetResolution() only returns the last confirmed resolution (doesnt change with r.setres)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [February 27, 2015, 2:32pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/9 "2015-02-27T14:32:33Z")

</div>

Hello ,

If you are looking for a solution in code, you will need to use ScreenPositionInvDPI. ScreenPositionInvDPI: The position in the viewport with the inverse DPI applied to it. This is useful for positioning child widgets of widgets in the viewport where you need to remove DPI before applying it. I hope that this helps.

---

<div class="post-metadata">

**Author:** ![m0useCat064](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@m0useCat064](https://forums.unrealengine.com/u/m0useCat064)\
**Post date:** [May 5, 2017, 5:24am UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/10 "2017-05-05T05:24:11Z")

</div>

I had a similar problem while trying to get a crosshair system to work, and I found an excellent solution in a forum post.

> **[Convert World Location to Screen Location bug ?](https://forums.unrealengine.com/showthread.php?60698-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...

Long story short, multiply the screen location coordinates by the inverse of the viewport scale.

[https://forums.unrealengine.com/attachment.php?attachmentid=34771&d=1428854684](https://forums.unrealengine.com/attachment.php?attachmentid=34771&d=1428854684)

(Yes, this question is over 2 years old, but I hope this answer helps someone searching around.)

---

<div class="post-metadata">

**Author:** ![ugdgod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ugdgod](https://forums.unrealengine.com/u/ugdgod)\
**Post date:** [September 4, 2020, 2:24pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/11 "2020-09-04T14:24:30Z")

</div>

Wow, this REALLY works as intended, AND it’s easy to integrate!  
I just divided the scale instead of using power -1, which is basically the same thing

---

<div class="post-metadata">

**Author:** ![BojanglesTheLess](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BojanglesTheLess](https://forums.unrealengine.com/u/BojanglesTheLess)\
**Post date:** [March 10, 2023, 4:21pm UTC](https://forums.unrealengine.com/t/umg-world-to-screen-space-vs-resolution/307379/12 "2023-03-10T16:21:24Z")

</div>

there’s a function called [Project World Location to Widget Position](https://docs.unrealengine.com/5.1/en-US/BlueprintAPI/Viewport/ProjectWorldLocationtoWidgetPosi-/), which I think is what should be used now.

> [@Convert World Location to Screen Location bug ?](https://forums.unrealengine.com/t/convert-world-location-to-screen-location-bug/22421/16):
>
> 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](https://docs.unrealengine.com/en-US/BlueprintAPI/Viewport/ProjectWorldLocationtoWidgetPosi-/index.html))
