Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | JonTGN |
Hello!
I am fairly new to godot and gdscript but have plenty of background knowledge in python. One thing I can’t seem to figure out is how to handle killing off my npcs. I have my player character and right now it’s set up to run the kill() function in my zombie node. The kill function simply frees the queue after checking if there is in fact a node via weakref(Sprite). However as soon as I run the kill() method it is giving me an error stating "Attempt to call function ‘kill’ in base ‘previously freed instance’ on a null instance. This led me to believe it’s trying to remove all sprites or that it deletes the zombie sprite and still tries to remove them? Please correct me if I’m wrong but I have no clue how to solve this. Also how would I spawn a new zombie after the old one dies? In my physics_process function I have an if stating if the wr is false, then add_to_group(“zombies”) but I can’t tell if that’s correct or not since the game crashes as soon as I run queue_free(). Any help would be appreciated. Thanks