public void shoot() { if (shootsInMagazine >= 1) { shootsInMagazine--; Vector3 shootOrigin = transform.TransformPoint(cannonRelativePosition); Vector3 shootEnd = new Vector3(); Vector3 rayDirection = getWorldDeviatedDirection(); RaycastHit hit; if (Physics.Raycast(shootOrigin, rayDirection, out hit, rayDistance)) { shootEnd = hit.point; IDestructible destructible = hit.transform.GetComponent <IDestructible>(); if (destructible != null) { destructible.damage(damage, user); } } else { shootEnd = transform.TransformPoint(cannonRelativePosition); shootEnd += rayDirection * rayDistance; } StartCoroutine(drawShoot(shootOrigin, shootEnd)); } }