How to set position of 2D node with respect to control node

Godot Version

4.4

Question

I want to set position for the GPU Particles (2D node) into the middle of TextureRect (control), lets say as a part of the UI (so that it shouldn’t move in regards to the player screen).
From what I understand, the way to put 2D Nodes into GUI is to put them on separate CanvasLayer to ‘freeze’ their placement.
However, I cannot locate the transform needed to put the particles relative to a control node (whose position is technically 0,0):

The particles are a child of the Drawer Node, which is situated into hbox/vbox containers with some added control nodes for margins.

Would appreciate any help/leads.

EDIT:
For global position of the drawer node:

print("Drawer node Global pos",global_position)

I still get:

Drawer node Global pos(0.0, 0.0)

Thanks,
Maks

For a node, position is where it is relative to its parent. global_position is its absolute position in the world.

see edit

When are you sampling that? It ought to be updating at runtime. If you put your print in the drawer script’s _process(), do you just endlessly get zeros?

Yeah, you were right - I was doing that during _ready, and so it was not detecting the transforms from the Drawer node’s parents.

My understanding is that _ready() or @onready are when the node enters the tree, but this doesn’t guarantee that all the surrounding setup is done. I’m not sure if there’s a “container layout change” signal you could hook, but if there is…

I’ve just used call_deferred to setup the particle node’s postion.

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