How to manage multiple Views? H/VBoxContainers seem bugged and keep resetting to wrong values...

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

Hi, so I’m trying to have a large view on the left, with two views stacked vertically on the right. (World with characters on left, two ‘action boards’ on the right; like mini-games).

I found a guide which recommended HBoxContainer, so I thought using a HBoxContainer to split left and right, then a VBoxContainer to split the right on top to bottom. It works, but I can’t get precise values to work… I want the right to be 540 pixels, which leaves 1380 pixels for the left:

Total = 1920x1080.
|- Left = 1380x1080
|- Right = 540x1080
… |- RightTop = 540x540
… |- RightBottom = 540x540

So I set every component’s Rect and Size values using the above values, and everything looks ok on the 2D view, but when I launch the game, the above sizes are not respected and while the gist of placement is respected, the sizes & ratios are wrong… If I close and re-open godot, then it screws up all the values, 1380 becomes 1231, 540 become 685, some heights become 538 instead of 540, so basically the same values I get when I launch the game… If it would be a few pixels it wouldn’t be the end of the world, but resizing from 540 to 685 or 1380 to 1231 is very annoying… (From square to rectangular…)

If I set all the values I want then save, the file contains the correct values, so I commit to Git. If I relaunch Godot, it screws up all the values of the file when loading the scene. The issue seems to be related to Margins… The editor’s Hint says that it should be controlled by the container and shouldn’t be edited…

But yeah I’m new to godot, is there a better way to manage split views than containers? Just seems bugged so far, there’s absolutely no error or output log about incorrect values being fixed or anything… I think I remember reading or watching a tutorial which said that for the Nodes; red = 3D, green = UI and blue = 2D, but the only way to place views seem to be through containers…

Thanks!

(Also could be an issue about some pixels overlapping; if I had a 4x4 pixel project and set 2x4 for right, and 2x2 top right and 2x2 bottom right, that would seem logical, but it seems from the values godot is ‘correcting’ to, it’s like there’s some pixels used as separators even though 0 is specified for separators… But I just tried reducing everything by a few pixels and the result is the same, so that’s not the issue…)

:bust_in_silhouette: Reply From: nwgdusr999

Ok I have no idea what is going on with the H or VBoxContainers, but I finally got it to work using 3 ViewPortContainers each containing a ViewPort containing a scene, and setting manually the size and location of each component.

It’s a bit annoying but the viewports & all default to 0 size and need to be set manually. But seems to work great so far! So for others attempting to do the same; a split view using multiple views, each scene needs a Camera with ‘current’ checked, and it can simply be:

Node 2D
| —> ViewPortContainer → Viewport → Scene
| —> ViewPortContainer2 → Viewport → Scene2
| —> ViewPortContainer3 → Viewport → Scene3

But yeah, I’d steer well clear of the HVContainers as there seem to be something bugged with them… Not confirmed as would require most testing, but I’m already hours into this so am really happy to move on!!!