I have an enemy script, which has the enemy health, ai and everything in one script. I made the script so that it would be easy to customize the enemy, thats the reason they are in the same script.
Unfortunately I have run into a problem when trying to make multiple enemies to my scene.
My script works like this: if life goes to 0, then variable “dead” is true, which triggers a function which deletes the enemy gameObject.
The problem with it is that whenever one enemy is deleted all of them are deleted. They all have same script attached to them and they all have same tag.
To solve that I tried destroying the enemy from another script. So the other script checks if the varialbe dead is true, and if it is then deletes target.gameObject.
This however doesn´t really solve the problem. I does prevent killing all of the enemies at once, but whenever one of the enemies is killed all of the others die with 1 shot even though it should take much more.
So I´m asking do the scripts with same name interact somehow? so when one script returns “dead = true”, then all scripts return “dead = true”?
And most of all I would like to know how to solve it, so that I could have many enemies.
hopes up, Siim