Fliping Screen Size in Game: is it possible?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lucasfazzi

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

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.

johnygames | 2019-08-12 17:09

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.

johnygames | 2019-08-12 17:28

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

lucasfazzi | 2019-08-12 20:56

:bust_in_silhouette: Reply From: lucasfazzi

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