private void Shoot() { timer = 0f; SoundController.Instance.PlayAudio(TypeAudio.GunShot); 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)) { EnemiesHealth enemiesHealth = shootHit.collider.GetComponent <EnemiesHealth>(); if (enemiesHealth != null) { enemiesHealth.TakeDamage(damagePerShot, shootHit.point); } gunLine.SetPosition(1, shootHit.point); } else { gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range); } }
public void Init(PlayerController playerController, EnemiesHealth enemiesHealth) { this.playerController = playerController; this.enemiesHealth = enemiesHealth; }