void Shoot() { timer = 0f; gunAudio.Play(); gunLight.enabled = true; faceLight.enabled = true; gunParticles.Stop(); gunParticles.Play(); gunLine.enabled = true; gunLine.SetPosition(0, transform.position); shootRay.origin = transform.position; shootRay.direction = transform.forward; if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) { Bombs_EnemyHealth enemyHealth = shootHit.collider.GetComponent <Bombs_EnemyHealth>(); if (enemyHealth != null) { enemyHealth.TakeDamage(damagePerShot, shootHit.point); } gunLine.SetPosition(1, shootHit.point); } else { gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } }
float timer; // Timer for counting up to the next attack. void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <Bombs_PlayerHealth>(); enemyHealth = GetComponent <Bombs_EnemyHealth>(); anim = GetComponent <Animator>(); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent <Bombs_PlayerHealth>(); enemyHealth = GetComponent <Bombs_EnemyHealth>(); nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); TrackPlayer(); }
void Explode() { foreach (Collider collider in Physics.OverlapSphere(transform.position, radius)) { Bombs_EnemyHealth enemyHealth = collider.GetComponent <Bombs_EnemyHealth>(); if (enemyHealth != null) { enemyHealth.TakeDemage(damage); } Bombs_PlayerHealth playerHealth = collider.GetComponent <Bombs_PlayerHealth>(); if (playerHealth != null) { playerHealth.TakeDamage(damage); } } Destroy(gameObject); }