Make sure you set the global_position AFTER adding the child

I made a mistake that might be interesting to others as well.

When creating a new shot, I first set the global_position, and only then called add_child.

This is wrong (I learned :-)), if you do it like that, the global_position will end up to be incorrect, as the node is not part of the scene yet.

For me, this resulted in projectiles appearing at the wrong place (seemed like their coordinates got multiplied by 2 :-)).

Maybe it helps someone, so therefore this post.

5 Likes

Privacy & Terms