private void Shoot() { if (paused) { return; } stateRecoil = true; Invoke("SetStateRecoilFalse", shootSpeed); GetComponent <AudioSource>().Play(); RaycastHit hit; LineRenderer newBullet = Instantiate(BulletPrefab, bulletStartPoint.position, mainCamera.rotation).GetComponent <LineRenderer>(); newBullet.SetPosition(0, bulletStartPoint.position); if (Physics.Raycast(mainCamera.position, mainCamera.forward, out hit, maxShootingRange)) { newBullet.SetPosition(1, hit.point); if (hit.transform.tag == "Creature") { // hit creature hit.transform.GetComponent <CreatureAnimationScript>().KillCreature(); warningScreen.Deactivate(); } else { // hit background } } else { // shoot into space newBullet.SetPosition(1, mainCamera.position + (mainCamera.forward * maxShootingRange)); } if (OnGunShoots != null) { OnGunShoots(); } }
public void EndChase() { warningScreen.Deactivate(); if (OnEndChase != null) { OnEndChase(); } }