void Update() { if (enemyLife.IsAlive() && playerLife.IsAlive()) { nav.SetDestination(playerTransform.position); } else { nav.enabled = false; } }
private void Shoot() { timer = 0f; shootRay.origin = cam.transform.position; shootRay.direction = cam.transform.forward * range; if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { EnemyLife enemyLife = shootHit.collider.GetComponent <EnemyLife>(); if (enemyLife != null && enemyLife.IsAlive()) { enemyLife.TakeHit(); audioSource.Play(); } } }