|
|
|
 |
Reply From: |
ibrahim.semab |
To change the screen orientation in code, you can use the Viewport node’s size_override property. Here’s an example code snippet that sets the viewport’s size override to the desired size for portrait mode:
var viewport = get_viewport()
viewport.size_override = true
viewport.size = Vector2(720, 1280)
This sets the viewport to a size of 720x1280 pixels, which is a typical portrait resolution for mobile devices.
You can use a similar approach to set the viewport size for landscape mode:
var viewport = get_viewport()
viewport.size_override = true
viewport.size = Vector2(1280, 720)
This sets the viewport to a size of 1280x720 pixels, which is a typical landscape resolution for mobile devices.
You may also need to adjust the position and size of other nodes in your scene to fit the new viewport size and aspect ratio. For example, you may need to adjust the position and size of your game board and game pieces to fit within the new viewport.
This (again) appears to be a completely unvetted ChatGPT (or similar) response that’s not valid.
@ibrahim.semab - I assume you’re trying to be helpful with this (and other) recent posts, but ChatGPT will happily (and confidently) offer complete garbage in response to many questions. Please attempt to validate any such responses prior to posting them here.
jgodfrey | 2023-05-02 15:50
You are almost right basically I am no longer a game developer and I was trying to be helpful plus I was just checking if ChatGPT’s information is correct but now I have realized that it’s just rubbish thanks for mentioning I just wasted my time
ibrahim.semab | 2023-05-02 16:28
I am not too Old I am just 15.
ibrahim.semab | 2023-05-02 16:30
I was just surprised that how youtubers used it to boost their productivity
ibrahim.semab | 2023-05-02 16:33
I just wasted my time
Not only have you wasted some of your time, but you’ve likely caused the relevant questions to no longer get any additional input. Generally, questions that are marked as having already been answered on the main page don’t get much additional attention… 
jgodfrey | 2023-05-02 17:15
Thanks for pointing this out. I did try this suggestion with no luck, and eventually gave up. I was going to pick it up again this week, which is why I’m back at my original post.
If I wanted a reply from ChatGPT, I would have used it myself. I hope this doesn’t become a trend, where people start replying on forums using AI to generate their answers trying to be “helpful”.
Ragnar Brynjúlfsson | 2023-06-11 17:52