Main script:
using UnityEngine;
using System.Collections;
public class levelScript : MonoBehaviour
{
public static int kills = 0;
}
second script when HP is equal to 0
using UnityEngine;
using System.Collections;
public class destroyEnemy : MonoBehaviour
{
void Update()
{
StartCoroutine (death());
}
IEnumerator death()
{
yield return new WaitForSeconds(6);
levelScript.kills =+ 1;
Destroy (gameObject);
}
}
When you kill the first opponent script adds +1 to the variable kills but another dead body add nothing to it. What’s wrong?