(Posted this on the discord but it got ignored, I thought I would try here)

I have a turn system that works as follows: - A Turn Queue node looks in its children to assign the top one as the active character. -After it gets the end turn signal, it shifts the current character to the bottom of the queue and assigns the new top one as the active character. -You can also make extra turns, which are duplicated versions of the active character node placed under it, and instead of moving to the bottom when the turn

my problem is that I run into this error after I delete an extra turn node and try to go to the next turn Attempt to call function 'turn_done' in base 'previously freed instance' on a null instance.

From my research, I think it's from me using queue_free() to get rid of the extra turns, and something about how Godot gets rid of the node?

the code is (also in an Image):

#checks if the turn was a base turn
  if active_charater.base_turn == true:
      #if base, replace the one at the top with one at the bottom
        self.remove_child(active_charater)
        print("got rid of" + str(active_charater))
        self.add_child(active_charater)
       print("added" + str(active_charater))
    else:
        #if extra, just delete it
        print("got rid of extra turn")
        active_charater.queue_free()

how do I remove the duplicated turn nodes without running into an error?

Did you remove the node from the queue before calling queue_free? You won't be able to access a node that doesn't exist anymore.

@duane said: Did you remove the node from the queue before calling queue_free? You won't be able to access a node that doesn't exist anymore.

I switched it from queue_free() to self.remove_child(active_charater) and now it seems to work!

thanks for the help

2 years later