0 votes

In my game the player has the ability to shoot a projectile but when ever the player moves so does the projectile. How do I fix it

Godot version 3.2.2
in Engine by (34 points)

2 Answers

0 votes

The projectile moves when your player moves because the projectile is a child of the player. Instead of using add_child() when instancing your projectile use get_parent().add_child().

by (3,707 points)
0 votes

You added the projectile as a child of the player node so when the player moves the projectile position changes accordingly

see this example for instancing nodes using signals:
https://docs.godotengine.org/en/stable/tutorials/misc/instancing_with_signals.html

by (14 points)
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 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 webmaster@godotengine.org with your username.