void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth> (); devilHealth = GetComponent <DevilHealth>(); anim = GetComponent <Animator> (); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent <PlayerHealth> (); devilHealth = GetComponent <DevilHealth> (); devilAttack = GetComponent <DevilAttack> (); nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); }
void Shoot() { timer = 0f; gunAudio.Play(); gunLight.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)) { EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> (); DevilHealth devilHealth = shootHit.collider.GetComponent <DevilHealth> (); if (enemyHealth != null) { enemyHealth.TakeDamage(damagePerShot, shootHit.point); } if (devilHealth != null) { devilHealth.TakeDamage(damagePerShot, shootHit.point); } gunLine.SetPosition(1, shootHit.point); } else { gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } }