- Edited
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)```