I don’t see anything wrong with my code, but when the script is supposed to take health from the enemy, it is throwing a null reference exception… I can’t figure out why.
void OnTriggerEnter(Collider collide){
if(collide.tag == "Enemy"){
Debug.Log("Hit Enemy!");
//collide.gameObject.GetComponent<EnemyScript>().Health -= damage;
eScript = collide.gameObject.GetComponent("EnemyScript") as EnemyScript;
eScript.Health -= damage;
}
}
Code should be pretty self-explanatory. Thanks for any help in advance.