Finding children position in global coordinates

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TKT

I had some exprerience in unity. There was an easy func ScreentoWorldCoord(pos) in there … Now what i want to know:

Lets say i have a parent node and it have a child node.

oParent
----oChild(SPRITE)

I have 1024x600 dimension screen. My parent is set_position(500,500) and my child set_position(12,-200) which means my children will have a global position in screen coord (512,300) …But its local position is (12,-200) this is what i understand from researching.
I want to know is there any function that will give me children’ global position in screen which in this case (512,300) .I tried get_global_transform and get_global_transform_with_canvas().origin and tried to see a some global values but it didnt work.
I believe there isnt one but what i want to get get_global_position_on_canvas(children_pos) kind of thing. There are some transform matrices informations but not sure how will i transform my position and see its global position.

:bust_in_silhouette: Reply From: Dlean Jeans

Have you tried global_position?

get_global_position() worked. Cant believe i didnt see such method when i searched it. Thank you.

TKT | 2019-07-02 12:57

Unless you’re using Godot 2.1. Why not just use .global_position? It’s shorter than get_global_position() and you can assign it as well instead of calling set_global_position().

Dlean Jeans | 2019-07-02 13:48

well i didnt know that one either. :slight_smile: thanks

TKT | 2019-07-02 16:10