Equivalent of anchors for 2D Nodes

Godot Version



I’m trying to find something equivalent to anchors for 2D-Nodes. I understand that anchors are only available for Control nodes.

I’m working on a mobile game on portrait mode. I want to keep an Area2D node at the bottom of the screen with a rectangle collision shape, it extends to the full width of the screen with about 1/5 of its height. I want it to maintain this rectangle ratio regardless of what resolution window is.

Currently I am working a 9:16 resolution ratio, however, when I change the window ratio to something like 3:4 the Area2D rectangle area does not extend dynamically with the window.

When I use Control nodes I am able to solve this problem with anchors. However, 2D Nodes do not have this option. Is there any feature in Godot to solve this issue for 2d nodes, or is my best option to change this through code?
Thank you!

You’re right, Node2d does not have anchors. You would need to calculate the shape and position based in the viewport sizes.

1 Like

Ah yes, so this is my only option then. You saved me a lot of needless googling time, thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.