The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hello people;

I don't know if this is possible, but I would like to know; Is it possible to do a reverse screen with one command? Like "pressing a button > changes the screen orientation"

Similar to the Mobile sensor, but done with a button within the game.

If anyone has a tutorial and it is possible, I would appreciate it; I have no idea even how to look this up in the forums

The picture sucks but illustrates my idea

in Engine by (174 points)

There's got to be a better way, but I figured you can achieve this by rotating the viewport. The way I managed to do that was by creating a BoxContainer node with a Viewport Container inside, the child of which is a Viewport node. The tree looks like this:


I just created a script and attached it to the BoxContainer and using the set_rotation() method, I was able to change the orientation of the screen.

As far as I know, the root of any scene is not the top node, but a viewport. Maybe you could rotate that root vieport directly, but I do not know how. Maybe something that has to do with canvas layers or so. That's why I am not adding this as an answer. If my solution covers you, though, let me know and I will turn this comment to an answer so that others can find it.

OK I figured another possible solution, but I can't test it. In your Node2D script try this:

extends Node

func _process(delta):
    if Input.is_action_pressed("<action1>"):
    elif Input.is_action_pressed("<action2>"):

Please tell me if this works.

I tried this method but with the documentation values ​​and it recognizes the command but it doesn't change anything

1 Answer

0 votes

Sorry for my ignorance, but isn't set_rotation() a Control Node only method?

by (174 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.