GetViewportSize() and ProjectWorldToScreen() don't match GetMousePositionScaledByDPI?

Hi, I’m having a lot of trouble understanding how the FOV and viewport sizes work at different system resolutions: I’m trying to move and resize world objects based on viewport size.

It started with some FOV experimentation. I placed a plane mesh at (0,0,0), and a camera facing down at (0,0,1500). The camera has an FOV of 90°, which means that the visible area should stretch from (0,-1500,0) to (0,1500,0) along the Y axis because triangles, but this isn’t the case - if I place a cube at (0,1500,0), it’s off the screen.

I figure it has something to do with resolution scaling, since if I move the cube into view and change the Standalone Window to say 300x900, the cube is smaller and in a different apparent place than in a 600x900 window. I used the BP node called GetMousePositionScaledByDPI and moved the mouse to the viewport edges to compare the values I was getting from PlayerController()->GetViewportSize(), and the BP node gives wildly different values depending on the viewport size, all different from GetViewportSize().

However, after a significant amount of digging I can’t find any documentation about accessing the resolution or DPI scaling that is actually happening. I want the camera in perspective mode, but have world objects scaling based on the user’s screen size (it’s a mobile puzzle game).
I also tried going from world to screen and back again with ProjectScreenToWorld and DeprojectWorldToScreen, and I wind up in two different places! like this:

  • Start at (0,-650,0);
  • ProjectWorldToScreen() returns screen position of (170,400) - viewport is 600x900;
  • Line trace from DeprojectScreenToWorld() hits plane at (0,-239.557,50) - plane is at (0,0,0) and 100 units tall;

Clearly there is some resolution scaling happening based on viewport size or something, but for the life of me I can’t find any information on what’s happening - though I know there’s something going on since the BP node has “scaled by DPI” in the name!

I also tried using screen percentage as detailed in this Answerhub post, but it kept giving me a screen percentage of 1.0000, and that’s when I had to take a frustration break and turned to community help.

I can’t figure out what I’m missing. I would really really appreciate if anyone could point me in the right direction here!
Thanks!