+1 vote

Godot Version: 3.1 BETA 1

Hi folks,

I'm having trouble scaling the viewport for different devices. Initially I was using the "2D" stretch mode... but this gets a bit wonky with aspect ratios that are different from the artwork. I've gone for a pixel art style so clean scaling is important.

I have my stretch mode set to "viewport" and aspect set to "ignore". Here is what I have tried...

viewport.set_size_override(true, new_size_v2, Vector2.ZERO)

The above seems to be ignored. The image is fullscreen and stretched.

viewport.size = new_size_v2

This didn't help, the artwork was still small in the top left corner.

viewport.set_attach_to_screen_rect(Rect2(position_v2, size_v2))

This does set the position and size correctly, but leaves the Godot splash screen in the background flickering.

Has anyone tackled this problem? If so, how did you get around it? Ultimately what I am looking to do is scale the viewport so that the game fits within the screen. Then, on devices with different aspect ratios, perhaps use a second viewport to render a background image to fill in the black bars.

Any input or pointers would be super helpful. Thanks :)

in Engine by (366 points)

Please log in or register to answer this question.

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.