Move child independently of parent

Godot Version

4.4

Question

Hi, I’m attempting to make a simple space invaders clone, and its going pretty well so far, except that I ran into an issue where when I spawn in a missile/bullet from the player, the bullet seems to be linked to that of the player. I was wondering how I would possibly unlink them so that the bullet travels in a straight line independent of the player? Ive attached my scene setup and the code for both the player and the child below.




The add_child() call will add a child to the current object unless you specify another. What you probably want to do is make a Missiles Node2D hanging off the scene root, and then do Missiles.add_child(shot).

1 Like

add_sibling will add the node next to the player. Since the missle wont inherit the player’s location anymore you will have to also copy that property

var new_missle: Node2D = missle.instantiate()
new_missle.position = self.position
add_sibling(new_missle)

Make sure to paste code instead of screenshots

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