I have a list of enemies. I am instantiating this enemy from list.
After the enemy is destroy i wana remove this enemy from list.
How do i do this
On destroy function i am using enemylist.remove(this.gameobject);
But it doesnt since spawned enemy is an instance of prefab from list.
If you are instantiating from a list and you don’t need to use that enemy prefab again, just remove it after you instantiate a clone. Or if you are creating several copies, just remove it when you create your last copy.
Then you need to record something about the index they are in. Either have a variable for the name, a variable for the Gameobject, or if you can only have one enemy from the list out at a time, then just use the index. @Zonlib gives you an example that would be similar to a string variable by naming the newly created object instead.