Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy not giving damage

$
0
0
I have an enemy that breaths fire and I had a NullReferenceException. I added ; if(EnemyHealthManager != null) to deal with it and while the enemy does breath fire, it does not give damage What could the problem be? public class MegalothAttack : MonoBehaviour { public float timeBetweenAttacks = 0.5f; public int attackDamage = 25; GameObject player; PlayerHealth playerHealth; EnemyHealthManager EnemyHealthManager; bool playerInRange; float timer; void Awake () { player = GameObject.FindGameObjectWithTag ("Player"); playerHealth = player.GetComponent (); EnemyHealthManager = GetComponent(); //anim = GetComponent (); } void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { playerInRange = true; } } void OnTriggerExit(Collider col) { if (col.gameObject.tag == "Player") { playerInRange = false; } } void Update () { timer += Time.deltaTime; if(EnemyHealthManager != null) <<= timeBetweenAttacks && playerInRange && EnemyHealthManager.currentHealth > 0) << 0) { playerHealth.TakeDamage (attackDamage); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>