Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | cardoso | |
Old Version | Published before Godot 3 was released. |
How to know the screen position of a node2D?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | cardoso | |
Old Version | Published before Godot 3 was released. |
How to know the screen position of a node2D?
Reply From: | volzhs |
node.get_global_pos()
But doesn’t the node.get_global_pos()
gives the position on the “world”?
If a camera is centered on a node, the node will always be centered on the screen (same screen position always), but the node global pos will be changed as the node is moved.
cardoso | 2017-08-15 12:33
Reply From: | YeOldeDM |
get_global_transform_with_canvas()
will return a node’s transform relative to your viewport. The o
property of this will be that transform’s origin (position if you will).
As of 3.1.1, o
had been renamed to origin
so get_global_transform_with_canvas().origin
Dlean Jeans | 2019-05-25 16:50
Perhaps i’m mistaken, but in my tests, get_global_transform_with_canvas().origin is giving me the global position, not relative to the viewport… how can i get that position? I need to use it on a shader.
p7f | 2019-07-26 22:54
It returns the position to the top-left corner of the window for me in the 2D Platformer demo. You probably wanna open a new question for this.
Dlean Jeans | 2019-07-28 05:12