add_child seems to be applied to the source file and not the created instance() !

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Riad

I have build a 1st person shooter. I create my environment by using a sort of “level constructor”. this constructor rely heavily on creating everything (floors, walls…) by using “add_child”.

So even when I shoot a bullet, the effect on the wall is whole created by “add_child”.

The problem: I play “Level 1”, I shoot on the wall (the whole is there). I exit my level. And come back to it a second time, I can see the bullet whole is still there!!!

How is it possible knowing I actually queue_free on my “level constructor” when I exited the level?!!

it seems like the “add_child” is not adding the node to the instance but to the “real file” !
So even when I create a new instance in my game, the “level construct” will simply bring what has been modified on the real file !

So here’s a little of the code:
new_level = preload(“res://scenes/constructor.tscn”).instance()
add_child(new_level)

//bullet is add as a code after the player shoots…

new_level.queue_free()

:bust_in_silhouette: Reply From: Riad

Sorry for the false alert!

I made a mistake creating the bullet in the main tree instead the constructor… so that explains why I was keeping seeing it