How can I get absolute position of control node?

Godot Version

4.1.3

Question

Hey so I have a following layout where the piles are control nodes wrapped with MarginContainers, adjusted by HBoxContainer.

Now as I try to add cards to any of these piles by retrieving the pile position and then adjusting the y-coordinate (as I had previously with no Control nodes) I receive the same position for all the piles.

Am I doing something wrong with Control nodes or is it just impossible get an absolute position when they are positioned by their parent? I am using piles’ global_position

I think you want to use get_global_rect().position

1 Like

Thanks! I in the end it wasn’t too much to trouble set the positions manually once I nailed down the right margin. It would be nice to have a relative size unit like eg rem in css. But anyway, I’ll try it if I end up refactoring (again).

It wouldn’t make sense because godot bakes the fonts into fixed size bitmaps at the start.

It wouldn’t make sense to instead of using pixels or worse, fractions of pixels, you could be able to set the sizes with a fixed-size base unit? Having the unit be the size of the base font is arbitrary, it could be anything. It’s how design systems work.