Godot Version
4.4.1 stable
Question
I’m trying to calculate the true usable screen width translated into the world (on mobile).
I can successfully calculate it using:
DisplayServer.screen_get_usable_rect().end.x / camera.zoom.x * DisplayServer.screen_get_scale()
BUT if my screen is in portrait mode, using get_screen_scale throws the calculation off. So I have to use
DisplayServer.screen_get_usable_rect().end.x / camera.zoom.x
on my google pixel 4, screen_get_scale()
returns the following values depending on the device orientation:
portrait: 1.35000002384186
landscape: 1.79999995231628
I assumed from the docs that it returned some value related to pixel density, but I suppose I am mistaken. I have two questions:
- What does DisplayServer.screen_get_scale() actually get?
- Why does my formula require me to ignore it if my phone is in portrait mode?