Get screen position of a Node2D

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


It seems get_global_transform_with_canvas() is no longer an option with Godot 3?

I’m attempting to have a CanvasLayer element appear directly above a character. I just need a method to return the position of the character relevant to the screen and camera.


y dont u make use of global script use it to get ur viewport rect

code | 2018-07-24 11:32

How would I then go about tracking a Position2D (for instance) within that space as it moves?

blueSuedeShoes | 2018-07-24 14:51

Why isn’t it a option anymore, the method still exist in CanvasItem?

coffeeDragon | 2018-07-25 09:23

:bust_in_silhouette: Reply From: blueSuedeShoes

As coffeeDragon pointed out, get_global_transform_with_canvas() is still an option - my mistake!

I was able to get the UI element to appear above the player’s head simply with

var player_pos = get_node("/root/Game/Player").get_global_transform_with_canvas()
var spawn_pos = player_pos.get_origin()
position = spawn_pos

Thanks everyone.