Struggling to understand subviewports, and UI nodes in general

Godot Version

whichever one is the most recent.

Question

What I want to do is pretty simple. I want to have an always present, opaque UI bar taking up 1/4 the side of the screen, and for the main gameplay area to be offset to the side. I’ve been told to use hbox with a subviewport and whatever else I need for UI. I’ve used a texture rect as a placeholder. I have the rest of my game parented to the subviewport, but when I run the game only the texture rect is shown. Pictured below is my node tree

I don’t get why godot can’t just be normal about UI. Why nodes???

You need to use a SubViewportContainer as the parent of the SubViewport node to be able to render it.

1 Like

IDK about that.

for this you can put the controls in a CanvasLayer and the node2D parallel to it. there’s no reason to use a subviewport container, all nodes are 2D.

Node2D
	|-> Node2D
		|-> TileMapLayer/etc
	|-> CanvasLayer
		|-> HboxContainer
			|-> Control (set to expand)
			|-> Control (set to expand)
			|-> Control (set to expand)
			|-> TextureRect (set to expand) #1/4rth of the screen

your controls should draw on top of the 2D elements. if you have a character that needs to move around, the camera has a drag option that can be made uneven.


you just don’t know how to use it. watch a tutorial on Control nodes.
all UIs I’ve used are like this, it is normal. Unity was a mess, everything was a GameObject with components. Godot has a theme system that allows for a very good workflow of: 1 - making the structure of the UI fast, without worrying about looks. 2 - theming. 3 - coding and animating elements with either Tweens or an AnimationPlayer.
It is very good.

2 Likes