Hi Guys I have a Problem. I have a script that shall give the Player XP when the Enemy Dies. but it doesn’t give any XP. Any Solutions :)?
SCRIPT:
using UnityEngine;
using System.Collections;
public class EnemyHealth : MonoBehaviour {
public int maxHealth;
public int curHealth;
public int giveXP;
public GameObject destroy;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
AddjustCurrentHealth(0);
}
public void AddjustCurrentHealth(int adj) {
curHealth += adj;
if(curHealth <= 0)
Die();
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
}
public void Die () {
Stats st = (Stats)GetComponent("Stats");
st.XP += giveXP;
curHealth = 0;
Destroy(destroy);
}
}