0 votes

I'm trying to keep some Control nodes in the corners of the window, yet when I resize it, they don't move and get cropped out of view (or alternatively don't expand outwards to match a larger window size).
Here's my tree:
scene tree

I've tried adding this to the Camera2D's script within _process():
get_viewport().size = OS.get_window_size()

I've also tried setting the UI rect_size to equal the Camera2D's get_viewport().get_visible_rect().size, and doing the same procedure (but targeting the UI node, not the Camera2D) for the Velocity Display and Cursor Info nodes.

The anchor values on the labels are actually a little strange, to be honest. I've got them set for -.4 on the Y-axis and .4 on the X-axis. In my head that means they should be located at -.4 * (screen_height) on the Y-axis relative to the Velocity Display react. Yet they correctly display inside the window (as long as I haven't resized it from the project setting).

Here's an image of the app at the project default of 1920x1080:
default res

And one where I've resized it in the vertical axis slightly. Note that the CursorPos and X-Velocity labels are no longer visible. Resizing horizontally does something similar.
modified res

If anyone knows what I might be missing, I'd appreciate some guidance.
An up-to-date (as of this post) version of my project is located here:

asked Jun 27 in Engine by DDoop (395 points)

are you using "Layout->Full Rect" on the control nodes?
enter image description here

try putting root control node outside of the camera2d node, as the position of the camera2d node may be affecting the positioning of the control node (just a blind guess)

1 Answer

+2 votes
Best answer

Your gui should not be child of your camera. It should be child of a CanvasLayer for example.

answered Jun 28 by p7f (2,650 points)
selected Jun 29 by DDoop

Precisely the answer, I read it somewhere else and hadn't gotten around to resolving this Q. Thanks

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.