How to change screen orientation with code

Godot Version

v4.2.stable.official [46dc27791]


Hello, I am wondering how to change the screen orientation for mobile in Godot 4.2? Everything I’ve found so far suggests using OS.set_screen_orientation, but this appears to have been removed since Godot 2.1 (based on the Godot docs page for OS), and have confirmed it just gives an error in 4.2.

Was this functionality moved elsewhere, or is it simply not currently available? What I want to do is have it effectively change the Display > Window > Handheld > Orientation setting at runtime…

It was moved to DisplayServer.screen_set_orientation()

1 Like