Position2D doesn't move with his parent

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

Position2D does not move with the camera, for whatever reason… I already tried with global_position, that’s not working either…does someone know why?

extends Camera2D

onready var north = $North
onready var east = $East
onready var south = $South
onready var west = $West
onready var player = get_parent().get_node("Player")

func _process(delta):

print(player.position.x,"   Position2D   ", east.position.x, "   Camera   ", position.x)

if (player.position.x > east.position.x):

	global_position = Vector2(256, 0)

:bust_in_silhouette: Reply From: ichster

Nodes apply their transform on top of their parent’s transform.

So for example, if Camera’s position is (10, 20), and North’s position is (5, 5), then North’s global position would be (15, 25). In this case, North would be offset from Camera by (5, 5).

In your case, if Camera’s global position is (256, 0), then each of the Position2D nodes would have an inherited global position of (256, 0) if their positions were (0, 0).