0 votes

basically this is how my player node is set up:


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

in Engine by (120 points)

1 Answer

0 votes
Best answer

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!

by (399 points)
selected by

thanks a lot ill try that

tysm, this helped me a lot

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.