var node = Button
# It's inside a loop, would be very extensive the entire code
var point_a = node.global_position
print(point_a)
The point is: the global_position or any other methods I’ve been trying these days, always return (0.0, 0.0), or the same coordinate (that I calculated as being the top-left of the first Panel)
Any other methods I could try?
Here are some stuff I tried and failed completely:
var point_a = node.??
?? would be:
{
global_position
position
get_global.position()
rect_position
get_parent().get_node(node.name).rect_position
get_local_position()
}
Do you access the global position in _ready? In that case the position is not yet finalized and you would need to wait one frame until the position is available.
Actually, the output of the coordinates are a Vector2, and the Vector2.x is correctly being printed, but the Vector2.y is the same in every Button.
Thank you, your answer really helped me a lot, but the Y vector is still buggy.
My Hypothesis:
Because I have a HBoxContainer and multiple VBoxContainers, the VBoxes are set correctly, but the Buttons not yet, but two awaits weren’t useful.
Edit:
ANSWER
Thank you, @Sauermann , you helped me a lot. I tried to place another await, after the dynamic VBoxes and before the coordenates, and that worked perfectly.