How to change viewport width/height in different scenes?

Godot Version

4.0.2

Question

I am putting together demos from different tutorials I’ve followed into one project. One of them has smaller assets, so I changed the viewport in the project settings to 480, 270 while making the demo.

I need to only have the viewport smaller for this one demo, but not sure how to change it at run time.

I’ve tried - ProjectSettings.set_setting(“display/window/size/viewport_width”, 1280)

  • ProjectSettings.set_setting(“display/window/size/viewport_height”, 720)*
    also just - get_viewport().size - but not working as intended. How can I make the viewport in project setting unique per scene?

I switch between demos from a title screen.

i think you still need to change the display/window/size/window_height_override and display/window/size/window_width_override values, not just viewport, because at the end of the day, it got override by those 2 values

Also these properties affect how you wanted it to look

image

also you get the project settings viewport value by

print(ProjectSettings.get_setting("display/window/size/viewport_height"))

get_viewport() just return the current Node’s viewport