I have an obstacle which the player can destroy. Once it's destroyed, the save file is updated so that the next time that room is loaded, I can check whether to load that obstacle or not.
That last part is giving me trouble. Currently, I am calling
queue_free() in the obstacle's
_enter_tree function as follows:
This works for now, but I can see it becoming a problem. It's a
queue_free so it and its children will have all their
_ready callbacks called, which I can see being a problem for more complex scenes. Calling
_enter_tree crashes with no information, and I don't think you're supposed to do that anyway.
I've considered making the obstacle a child of a custom "ConditionalLoader" node or something like that, which would instantiate the obstacle at runtime depending on what the save file says. That means I won't be able to edit the child in the scene it's going to appear in, and in this particular case that's a dealbreaker.
My ideal solution would be if I could override some theoretical
should_enter_tree callback, but if anything like that exists, I couldn't find it.
Are there any better solutions than what I'm doing at the moment?