How do you get screen orientation sensors data ?
Asked Answered
B

1

0

Hello, I tried this on Godot 3.5.2 stable

  • I added '$Label.text = str(OS.screen_orientation)' in _process function

  • I set my Android phone to allow orientation detection.

  • I export the game.

  • I ran the game then I move the phone to landscape orientation.

The label always prints "1". I expected the value to change.

I just need to detect the real device orientation so my game can adapt.
Is my method wrong ?

Bilicki answered 10/8, 2023 at 10:55 Comment(0)
B
0

When I set OS.screen_orientation to 6 the game display is rotated automatically, it doesn't relies to the game code
I can detect the current orientation by getting the window_size. If the x is bigger than y it is on landscape mode.

Bilicki answered 10/8, 2023 at 18:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.