0 votes

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.


I have 1024x600 dimension screen. My parent is setposition(500,500) and my child setposition(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 getglobaltransform and getglobaltransformwithcanvas().origin and tried to see a some global values but it didnt work.
I believe there isnt one but what i want to get getglobalpositiononcanvas(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.

asked Jul 2, 2019 in Engine by TKT (35 points)

1 Answer

+2 votes
Best answer

Have you tried global_position?

answered Jul 2, 2019 by Dlean Jeans (3,911 points)
selected Jul 2, 2019 by TKT

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

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().

well i didnt know that one either. :) thanks

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.