position2d not following parent and grandparent

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

basically this is how my player node is set up:

>KinematicBody2d
    >Sprite
       >position2d

and i want bullets to spawn at the position2d’s position
but when i try to they spawn at
i printed out the bullets position and the position2d’s position which are the same (7.3,-0.8) so i’m sure it’s a problem with the position2d node

and when i walk around with my player the position doesn’t change
so the node isn’t following it’s parent

:bust_in_silhouette: Reply From: RedBlueCarrots

Try using position2d.global_position instead of just .position. Just saying position says its position relative to it’s parents, so in this case, even if the player moves to the left, the position2D’s position will remain (7.3, -0.8), because that’s where it is relative to the player

global_position simply returns your position relative to the whole screen, which i think is what you want in this case.

Hope this clarifies things a bit for you!

thanks a lot ill try that

ROBOTOO007 | 2020-08-05 09:58

tysm, this helped me a lot

blue_robin | 2021-09-06 01:04