In my game I have it where the player can collect gems - though it seems that when I collect them and then die to an enemy, the player does the die animation but does not ‘self.queue_free()’ and return to the main screen scene. I have tried to do just ‘queue_free()’ to see if that would get rid of the gems, but ran into the same issue. It does not pop up as an error in the debugger either.
Is there a simple way to code to remove items from a players inventory?
Hey @wchc, I’m jumping in since I’ve faced a similar issue. If the player or inventory holds references to objects (like collected items), queue free() might not work as expected because those references can prevent proper cleanup. In my case, I had to manually clear the inventory data before calling queue free() on the player. It seems Godot 4 handles node lifecycles a bit differently, so cleaning up explicitly can help avoid lingering issues.
I have the gem variable at the top and then the amount at the bottom.
It could be another issue entirely I’m not 100% - I’m just running out of ideas on why he won’t return to the main scene
So you want to reinstatiate the game scene after dying.
I think you can completely skip the queue_free lines and go straight to the change_scene line after the animation stops playing. The Knight will be automatically removed and reinstatiated with the scene.
Can you try that?