This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
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.

in Engine by (35 points)

1 Answer

+3 votes
Best answer

Have you tried global_position?

by (4,246 points)
selected by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.