Viewports display nothing as i'm using them.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JBlechel

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 my case, I activate the tranparent_bg property and the sprite looks. I still can’t understand how viewports really work in godot

estebanmolca | 2019-12-28 06:39

:bust_in_silhouette: Reply From: estebanmolca

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

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.

JBlechel | 2019-12-31 18:43