void Shooting() { gunShoot.Play(); animator.SetTrigger("Shoot"); shootParticle.Play(); RaycastHit hit; Vector3 direction = shootPoint2.transform.position - shootPoint1.transform.position; if (Physics.Raycast(shootPoint1.transform.position, direction, out hit, Mathf.Infinity)) { if (hit.transform.gameObject.CompareTag("Player")) { PlayerHit playerHit = hit.transform.gameObject.GetComponent <PlayerHit>(); playerHit.RestartLevel(); } else { if (hit.transform.gameObject.CompareTag("Enemy")) { EnemyHit enemyHit = hit.transform.gameObject.GetComponent <EnemyHit>(); enemyHit.Dead(); } } } }