Add_child works fine, but add_sibling, does nothing [SOLVED]

I am trying to make a enemy shoot a bullet, and it works fine with add_child(), but it just does not work at all with add_sibling.
I put a piece of code in the bullet scene,

func _process(delta):
	print("bullet exists")
	position.y -= 1000 * delta

And apparently, if I use add child, boom, a thousand output messages, but if I use add_sibling… silence, not even a error shows up.
does anybody know anything about this?

Do you get any errors or warnings? Are you trying to add sibling on the tree root? Can you paste the add_child part of the script.

No errors, no warnings, I changed the original project by a bit and somehow it works, but I still don’t know why so I am right now trying to figure out why add_sibling sometimes act like pass in a test project.

I figured it out. In my original project, I had tons of errors due to this specific error:

The parameter “delta” is never used in the function “_process()”. If this is intended, prefix it with an underscore: “_delta”.

Since I’m still a newbie game developer, I only really noticed errors that made the game crash, and I totally ignored the errors from the debugger.

Apparently, add_sibling() only works after a certain amount of time of the node existing, so if you use add_sibling() in the ready() function without any delay, you get no sibling, and only this error

E 0:00:05:0439 add_printer.gd:8 @ _ready(): Parent node is busy setting up children, add_sibling() failed. Consider using add_sibling.call_deferred(sibling) instead.

When I thought of errors I only thought of game crashes XD

1 Like