protected virtual void Hit(GameObject hit) { PlayerHealthAndDeathManager healthManager = hit.gameObject.GetComponent <PlayerHealthAndDeathManager>(); if (healthManager != null) { healthManager.DamagePlayer(damage); } Destroy(gameObject); }
// Attack will happen once per frame void Update() { timer += Time.deltaTime; if ((isPlayerRange == true) && (timer >= timeBetweenAttacks)) { AttackPlayer(); // Call attack function to damage the player } if (playerHealth == null) { playerHealth = PlayerController.singleton.gameObject.GetComponent <PlayerHealthAndDeathManager>(); isPlayerRange = false; } }
void Start() { player = PlayerController.singleton.gameObject; playerHealth = player.GetComponent <PlayerHealthAndDeathManager>(); }