0 votes

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)

Godot version v3.4.1.rc1.official [7b0801c7f]
in Engine by (160 points)

1 Answer

0 votes

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).

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