Hi, I’m having the exact same problem as the person here, and the answer given does not make sense. There is no relevant field exposed in the inspector.
After some troubleshooting, enemy.RewardGold(); works just fine when used in the enemyMover class. Something in my enemyHealth class is wrong and I can’t identify the issue. Could someone please help?
public class enemyHealth : MonoBehaviour
{
[SerializeField] int maxHealth = 5;
[SerializeField] int currentHealth;
Enemy enemy;
void start(){
enemy = GetComponent<Enemy>();
}
void OnEnable(){
currentHealth = maxHealth;
}
void OnParticleCollision(GameObject other){
ProcessHit();
}
private void ProcessHit(){
currentHealth--;
if (currentHealth < 1){
gameObject.SetActive(false);
enemy.RewardGold(); // <---- This is the line that makes it cry.
}
}
}