So I have a Player character and an Enemy character, each with a Health Script and an Attack script. (PlayerHealth, PlayerAttack, EnemyHealth, EnemyAttack). The way it’s supposed to work is that the Attack script references the opposites Health script for the damage calculation. It was working fine for all of my testing until suddenly when I started to press “Play” it looks like the “EnemyHealth” script disappears from the “PlayerAttack” in the inspector? Even though I have dragged it into the appropriate slot, suggestions? Here’s an example of the code I’m using below…
using UnityEngine;
using System.Collections;
public class PlayerAttack : MonoBehaviour {
public EnemyHealth eh; //References the EnemyHealth script
}
void Start () {
GameObject go = GameObject.FindGameObjectWithTag(“Enemy”);
ph = (EnemyHealth) go.GetComponent(typeof(EnemyHealth));
}