How to get the position of a node relative to another node?

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

I’m trying to make an infinite background and ground but I ran into the problem that because the camera moves I don’t know the position of the background relative to the top left corner of the camera. And I don’t know how to get that position

you can get the top left corner of the camera like this:

var c= #get the camera node
var top_left=c.get_camera_screen_center()
top_left[0]-=get_viewport().size[0]*c.zoom[0]/2
top_left[1]-=get_viewport().size[1]*c.zoom[1]/2

jzzzzz | 2020-12-01 22:51

Thank you for a solution!

BlockOG | 2020-12-09 18:53

:bust_in_silhouette: Reply From: scrubswithnosleeves

Use a ParralaxBackground node with parallax layers and set mirroring enabled. it should do that all for you.

Here’s a good tut: