|Topic was automatically imported from the old Question2Answer platform.
For a while I have been struggling with my game crashing randomly when I try to check if a node is in a scene. I have tried to explain my issue, but as I am new to Godot, I seldom understand what people mean and I am unsure how to apply their answer to my problem.
I asked this question: Avoid getting "Invalid get index (previously freed instance)" error? - Archive - Godot Forum
I have uploaded my project, so you can see what I mean when I describe my issue: https://ufile.io/aa7ic
Junk spawns randomly and the crabs can pick it up. When they drop it in the bins, the junk is deleted. Sometimes the game crashes, because it tries to run the code, where the crabs carry the junk after they dropped it. I test if the crab is carrying the junk by saying
if carried_object: before manipulating the node. However, sometimes (and I have not found a pattern) it ignores the fact, that I check if the node exists and still tired to update its position. I tried to print out the node and at the moment it crashes,
carried_object is called
[Deleted Node]. This is driving me crazy as I cannot find anything online about it. If you have a suggestion, I would be very happy to receive it.
Thanks a lot!