Prefabs sharing variables

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?

mind posting your code so we can see exactly what may be wrong?

–

I'm blind... yes that was the issue, didn't know static variables would do that to all the prefabs.

–

The whole point of static variables is that there's only one instance.

–

I thought static var was used for being able to access them from another script

–

> 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

–

1 Answer

1

Have you set any variables to static within the class?