How do i get the position of a body/node related to the screen.
for example i have the body on the screen of the camera, let’s supose that the camera size is 1500 by 790, then i want to see the position of the player relatedto that screen size, similar to:
camera.get_viewport().get_mouse_position(), but the mouse position being the player position.
It is generally not a good idea to work with screen coordinates. That can become a real nightmare when window sizes change etc.
However you can read about transforms here:
But I think you need something like (untested):
var screen_position = my_node.get_global_transform_with_canvas().origin
But, there are a lot of things to take into account, like camera offsets, camera zoom (I believe you need to just multiply it by this but have not tested it) and your camera needs to be in the same coordinate space as your node.
TBH, I cannot think of a reason to do this. If you describe the reason we might be able to suggest a better approach for you.
Thanks a lot! Just to clarify things , i wanted to use the coordnates to see if the player had reached a certain point on the camera, so the camera could move to the side, but it seems not to work.
If you want to get the 2d screen position of a 3d position in the world (which I assume is what your question is, sorry if I misunderstood that) you can use Camera3D.unproject_position.