enemis live script

hi I used static variable for save and show enemies live

using UnityEngine;

using System.Collections;

public class enemyLive : MonoBehaviour { public static int enemyLiveScore=5; public int showLive; // Use this for initialization void Start () {

}

// Update is called once per frame
void Update () {
    showLive=enemyLiveScore;
if(enemyLiveScore<1)
    {
        animation.wrapMode=WrapMode.Once;
        animation.CrossFade("die",0.3f);
        Destroy(this.gameObject,10.0f);
    }
}
public void dieScore()
{
 enemyLive.enemyLiveScore--;
}

}

when I call enemyLiveScore--

enemyLive.enemyLiveScore--;

, enemyLiveScore loss for all enemies, who can I use it for special per enemy. thanks alot and sorry for my weak en language

to easy just quit to set it in enemyLive because that, what it does is atually to set a value to all the enemies or characters that has that script.

you dont have to actually quit to set it static, you can do it, but in the part of enemyLive.enemyLiveScore--; you need to quit the enemyLive. so get something like this:

enemyLiveScore--;

That's because your variable is static and therefore global. If you create a variable such as "`var lives = 3`" and put it in a script that is on each enemy, then only their copy of "`lives`" will be decreased if you call something like `lives--;`