For some reason it seems like each of my prefab enemies share the same variable. If I use Destroy(this.gameObject); it will destroy a single prefab but if I give all the enemies health and attack 1 enemy then all the other enemies will die when any other enemy dies. I want them all to have their own seperate scritps / variables. Is this possible?
1 Answer
1Have you set any variables to static within the class?
mind posting your code so we can see exactly what may be wrong?
– dannyskimI'm blind... yes that was the issue, didn't know static variables would do that to all the prefabs.
– jessee03The whole point of static variables is that there's only one instance.
– Eric5h5I thought static var was used for being able to access them from another script
– jessee03> I thought static var was used for being able to access them from another script Public variables are used for accessing from another script, using GetComponent, as covered in the docs. http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
– Eric5h5