What is the difference between global and local coordinates?

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

And as for global/local coordinates of Node2D children nodes?

:bust_in_silhouette: Reply From: i_love_godot

Local co-ordinates are relative to the parent that the node is a child of. Global co-ordinates are an exact position on the screen (including off-screen space).

For example if you have a Node2D positioned at x:50, y:100 in the main scene. If you add a child node (say a Sprite), that Sprite will have a local position of 0,0 but a global position of 50, 100. Let’s imagine you want to move the Sprite 10 pixels to the right. You set it’s position to 10,0 which is relative to it’s parent. Now it has global co-ordinates of 60, 100 and local co-ordinates of 10, 0.

I’m not sure if that explanation makes it any clearer, but I hope it helps :smiley:

That was an excellent explanation. Thank you so much!

bonsaipropaganda | 2023-05-08 15:19

:bust_in_silhouette: Reply From: Bishop

local = object space
global = world space
…imagine that you are sitting in the car and the car is moving…space in the car is local space and the car is moving in global space.
…you are child of the car.

Never knew cars can have kids. (good analogy btw)

TheoTheTorch | 2021-12-26 23:38