|Topic was automatically imported from the old Question2Answer platform.
Lets say I have a node and it has a child node named “target”.
“If $target” causes problems because a “previously freed instance” passes that check for some reason. Same goes for “if $target != null”.
“if $target is Node2D” seems to work better, but will still on rare occasion give me the error “get_node: Node not found: target”. It doesn’t crash the game so that’s something, and I assume it still returns false like its supposed to, but it seems like it causes a bit of lag.
It’s nothing that ruins the game or anything, but it seems like there should be an error free method to check if a node still exists. And preferable a method that doesn’t only work to test if a node has a child node with a specific name, since I also use this for variables.