diogo One way I have found to create permanence is to create an array of values with a different one for each enemy instance.
For instance, put this in a global autoload named Global:
var _enemyPermanence = []
This gets you an empty array. This is what you check to see if your enemy spawns. By exporting, you can make it unique for each enemy in the Inspector.
Put this in your enemy object:
export var _permanenceValue : String ## you could also do int, less memory that way
Then it's a simple check in the enemy. When you defeat them, place their value in the global array. If it has the value, you queue_free
them at the _ready()
function.
Like this:
if Global._enemyPermanence.has(_permanenceValue):
self.queue_free()
else:
pass
Only caveat to this is that arrays can get big over time and that can affect loading. May want to make separate arrays for areas, objects, blah blah, to keep memory from churning, although I think you have to get pretty big before that happens. Hope that helps. Oh! And with this method, make sure to put a key in before testing or the enemy will remove itself (because NULL is a value the computer recognizes, even in arrays)