0 votes

How could I change BY CODE the viewport size to fit different physical screen dimensions and aspect ratios?

Godot version 3.3.2
in Engine by (20 points)

1 Answer

–1 vote

Well I havent implemented the code below but according to the documentation ( see here https://docs.godotengine.org/en/stable/tutorials/viewports/viewports.html ) this should work,

Var Width_Set = 0
var Height_Set = 0

viewport.set_size_override(true, Vector2(Width_Set, Height_Set)) # Custom size for 2D.
viewport.set_size_override_stretch(true) # Enable stretch for custom size.

Tie the WidthSet and HeightSet variables into some user inputs and you should be able to set the size. If you check the website I directed too though it should give you more info.

by (1,417 points)
edited by

Thanks but your suggestion didn't work.

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 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 webmaster@godotengine.org with your username.