public void shoot() { RaycastHit hit; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) { test.Play(); Debug.Log(hit.transform.name); DestroyableObject ob = hit.transform.GetComponent <DestroyableObject>(); if (ob != null) { ob.getHit(damage); } } }