Projectile spawn child object is inheriting player values

Godot Version

4.4

Question

I have a player, and I set a node2D as a child of the player; this is my spawn for projectiles. Now I spawn the projectile scene and then instantiate it to be launched from the child spawn. The problem is that the projectile is inheriting player values. So if the player shoots and then jumps, the projectile, after being spawned, jumps too. So this doesn’t really work easily like Unity does. How can I make the projectile become independent when spawned? Or ignore player values?

Hello! Can you show your code please? And a sample video if possible? It will be easier to understand with code (and perhaps a bit of visual aid).

You’re probably spawning the projectile as a child of the player. Something like

add_child(projectile)

What you need to do instead is spawn the projectile as a child of the current scene. Like that

get_tree().current_scene.add_child(projectile)

And a difference Godot vs Unity has nothing to do with it. If you put a GameObject as a child of another GameObject in Unity, their movement will also be bound together, same as with Godot. It’s not a “bug”, it’s a feature :slight_smile:

1 Like

true, but unity handle it different on how you spawn objects and such. anyway thx for the help. i am still learning godot on the way.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.