+5 votes



It seems getglobaltransformwithcanvas() 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.


in Engine by (40 points)

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

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

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

1 Answer

+3 votes
Best answer

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.

by (40 points)
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.