0 votes

I've been unable to get them to work properly even at the most basic level.

I've created two ViewportContainers inside an HBoxContainer, added Viewports to each, and added a sprite to one with the Godot logo... nothing shows up. I've tried setting the ViewportContainer to stretch and that gives me a black screen, usage is set to 2d.

Whats missing here?

in Engine by (30 points)

In my case, I activate the tranparent_bg property and the sprite looks. I still can't understand how viewports really work in godot

1 Answer

0 votes
Best answer

Well, doing tests, I think the problem is the size of the viewports, which remain at zero. Deactivate and reactivate the Expand horizontal property on the size flags in each viewport container. This updates the size that the hbox container assigns to each viewport container, in this case it divides in the middle of the screen. Assign a sprite as children to each viewport and can be displayed correctly. Now the position (0,0) of the sprite in the viewport on the right is the center of the screen, and as expected, its image is cut if it goes beyond the limits of its parent viewport. Try it and tell me, maybe I change something else and I didn't realize

by (2,242 points)
selected by

oof. yup, thank you for the help. Who could've thought a viewport with no area wouldn't work very well... I've found Godot pretty easy to learn so far, but I'm still doing a bit of groping about in the dark with it.

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 Frequently asked questions and 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 [email protected] with your username.