Godot Version
4
Question
I have this cannon that rotates towards an enemy but when that enemy dies the game crashes because there is nothing to target and its being asked to target something that's not there, how do I fix this or how would you code it? I would like it to switch targets to other enemy once that one is dead or out of range and to focus on the closest target, is there a class system I can use so the cannon would know what to aim at even if it's not the same enemy, I lack code as I don't know how to code such a thing with these problems in place