create an autoload script.
for example called "gamedata"
on that script create a variable called for example
var uniqueenemylist = [ ]
or
var uniqueitemslist = []
then on your enemy sript,
create hima variable "numberID"
go to the ready function, and check if that ID is in the
gamedata.uniqueenemylist, if it's there, queue.free()
otherwise, it will be spawned as normal.
and write :
export var numberID = 0 # being an export variable, so you can make multiple of these enemies and only change this variable on the editor.
func ready():
if gamedata.uniqueenemylist.has(numberID ):
queue.free()
no need for else statement.
and once you killed that enemy or caught that item go and add it to that list.
gamedata.uniqueenemylist.append(numberID)
so the next that you load the scene, it will check in the ready function and it will queue free instead of spawning.
:) what do you think?