//gun has shot andhits npc private void Shoot() { RaycastHit hit; if (Physics.Raycast(_gunBarrel.transform.position, _gunBarrel.transform.right, out hit, _gunRange)) { Debug.Log("Gun hitted " + hit.transform.name); if (hit.transform.tag == "Enemy") { EnemyAi target = hit.transform.GetComponent <EnemyAi>(); if (target != null) { target.NpcRecivesDamage(_gunDamage); } } } }