Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS.get_screen_orientation() returns LANDSCAPE, although project is set to PORTRAIT on android. #17109

Closed
footurist opened this issue Feb 28, 2018 · 16 comments

Comments

@footurist
Copy link

Both Project>Export>Screen>Orientation and Project>Project Settings>General>Handheld>Orientation are set to Portrait and when I call the above function on device it always returns 0, which stands for Landscape. Is the bug from Godot 1 somehow back or am I missing something?

@aaronfranke
Copy link
Member

aaronfranke commented Feb 8, 2019

@footurist Does this still happen with Godot 3.1? Which version of Android and which device?

@KoBeWi
Copy link
Member

KoBeWi commented Apr 29, 2019

Still happens in 3.1 stable.

Tested on Xiaomi Redmi Note 4 with Android 7.

@shrewdlogarithm
Copy link

shrewdlogarithm commented May 29, 2020

I just ran into something like this - my setup is Godot 3.2 deploying to an Android 10 device.

If I set Project display mobile orientation to 'SENSOR' I can deploy and the game will 'rotate' as I turn the phone (as I'd expect) however OS.screen_orientation is ALWAYS 0 - which is clearly wrong.

Update: if I set 'PORTRAIT' it's still 0 - 'LANDSCAPE' it's STILL 0 - e.g. all it ever returns is 0 which is nonsense.

Furthermore - I'd suggest this should return the actual orientation of the phone - not the game.
e.g. how the use is holding it the device - I don't need to know it's "working as I asked" and I DO need to know if the user is holding the phone 'other than intended'

Reason: I'd like to lock my game into LANDSCAPE but adjust it's UI depending on how the user is holding the device - works for me but can't be done as-is?

@HEAVYPOLY
Copy link
Contributor

HEAVYPOLY commented Sep 24, 2020

Confirmed here, using 3.2.3 stable and Samsung note 9
Project Settings:
Orientation:Sensor

Export Settings:
Android:
Orientation: Portrait (no option for auto/sensor? Only Portrait or Landscape)

OS.get_screen_orientation() is always 0, even though the app is switching orientations based on phone orientation.

Also switches orientation regardless of the phone's Android OS Lock Rotation setting being on or off

@m4gr3d m4gr3d added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 13, 2020
@m4gr3d
Copy link
Contributor

m4gr3d commented Nov 13, 2020

The issue is already fixed on the main branch by e167af3. The fix will be backported to 3.2 by #43022.

@m4gr3d m4gr3d closed this as completed Nov 13, 2020
@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 13, 2020
@akien-mga akien-mga added this to the 4.0 milestone Nov 13, 2020
@akien-mga
Copy link
Member

@m4gr3d FYI, the cherrypick:3.2 label is only for PRs which are meant to be cherry-picked once merged in master.

There's no way currently to provide information about an issue being fixed both in 4.0 and in a 3.2.x release via a cherry-pick. In this case we just set the milestone of the first branch where it's fixed from the start (4.0).

@anisc
Copy link

anisc commented Nov 15, 2020

Is this fixed or going to be fixed ? I'm using 3.2.3 and still have the same issue OS.get_screen_orientation() return the same value (0).

@m4gr3d
Copy link
Contributor

m4gr3d commented Nov 15, 2020

@anisc It's fixed on the master branch, and the fix will be backported to Godot 3.2.4 by #43022

@anisc
Copy link

anisc commented Nov 15, 2020

@m4gr3d Hopefully, just checked the changelog for Godot 3.2.4 beta 1, there is no mention of it :(
But of course there is more pressing issue, thank you so much!

@Calinou
Copy link
Member

Calinou commented Nov 15, 2020

@anisc That pull request was merged after 3.2.4beta1 was released. It will be present in 3.2.4beta2.

@ChildLearningClub
Copy link

ChildLearningClub commented Apr 15, 2022

I'm getting OS.get_screen_orientation() returning the value (0) in 3.4.2.stable. Am I missing something?

@KoBeWi
Copy link
Member

KoBeWi commented Apr 24, 2022

Well, did you change the orientation? :P
I tested and it works fine in 3.5 beta4. However the description is a bit misleading. It returns whatever you have set in Project Settings, not the current orientation (i.e. using sensor doesn't change the value).

@ChildLearningClub
Copy link

ChildLearningClub commented Apr 25, 2022

Sure enough, it just spits out what you have set in the project settings. Thank you for clarifying @KoBeWi

@Zireael07
Copy link
Contributor

I guess this should be labeled as a documentation fix?

@KoBeWi
Copy link
Member

KoBeWi commented Apr 25, 2022

I'd open a new issue.
Also we might consider changing the behavior or adding a new method that returns the actual orientation..

@hiulit
Copy link

hiulit commented Apr 4, 2024

Did someone open a new issue? I can't find it and the "issue" of OS.get_screen_orientation() not returning the current screen orientation but rather the property set in Project Settings it's still present in 3.5. Should I open a new issue?

The problem I'm facing is having to deal with notches and whatnot, so the game fits the screen properly. Having a function to detect the current orientation would be very helpful, in conjunction with OS.get_window_safe_area(), to detect where the notch is and apply the proper margins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests