I'm not sure how to get the global or local position of nodes inside of a container.

I have a HBoxContainer that's setup with 7 TextureRects and a path that is setup outside of the control that's overlaid on top.
What I'm wanting is to create a PathFollower along that path that matches each TextureRects position. This will be used later on to "slide" the nodes along the path using a tween.

However the position of each TextureRect always returns (0,0) and global_position (0, -2). I already have a better idea of how to do this without using the position of UI but I'm curious on why the container nodes don't return the position I can see in the editor.

@export var possibleCards_ui: HBoxContainer
...
func _ready():
    print(possibleCards_ui.name)
    for child in possibleCards_ui.get_children():
	print(" --" + child.name + " global_pos:" + str(child.global_position) + " pos:" + str(child.position))
	var new_pathFollower: PathFollow2D = PathFollow2D.new()
	new_pathFollower.global_position = child.global_position
	path.add_child(new_pathFollower)
	pathPoints.append(new_pathFollower)
` ``

output:
```PossibleCards
 --Card1 global_pos:(0, -2) pos:(0, 0)
 --Card2 global_pos:(0, -2) pos:(0, 0)
 --Card3 global_pos:(0, -2) pos:(0, 0)
 --Choice global_pos:(0, -2) pos:(0, 0)
 --Card5 global_pos:(0, -2) pos:(0, 0)
 --Card6 global_pos:(0, -2) pos:(0, 0)
 --Card7 global_pos:(0, -2) pos:(0, 0)```
  • Godot probably needs a frame to do the layouting. Try to put the section of the code with the print statement behind a call_deferred.

Godot probably needs a frame to do the layouting. Try to put the section of the code with the print statement behind a call_deferred.

    Zini That was it,
    I moved the logic to it's own function and used call_deferred to call it and got the expected output.

     --Card1 global_pos:(48, 2) pos:(48, 0)
     --Card2 global_pos:(309, 2) pos:(309, 0)
     --Card3 global_pos:(570, 2) pos:(570, 0)
     --Choice global_pos:(831, 2) pos:(831, 0)
     --Card5 global_pos:(1092, 2) pos:(1092, 0)
     --Card6 global_pos:(1353, 2) pos:(1353, 0)
     --Card7 global_pos:(1614, 2) pos:(1614, 0)

    Thank you!