private void GunShot(GunLaserScript gunControls, RaycastHit hit) { if (hit.collider.gameObject.tag == "Enemy") { GameObject enemy = hit.collider.gameObject; HealthScript enemyHealthScript = enemy.GetComponent <HealthScript> (); if (enemyHealthScript) { enemyHealthScript.Hit(gunControls.damage); } } if (hit.rigidbody) { hit.rigidbody.AddForceAtPosition(transform.forward * gunControls.RayStrength, hit.point); } }
public void Shoot() { if (!PlayerControl.crawl && !box_script.isCovered) { if (gun) { GunLaserScript gunControls = gun.GetComponent <GunLaserScript> (); gunControls.Shoot(); Vector3 forward = gun.transform.TransformDirection(Vector3.forward); int ShotLength = gunControls.ShotLength; int RayStrength = gunControls.RayStrength; RaycastHit hit; if (Physics.Raycast(transform.position, forward, out hit, ShotLength)) { GunShot(gunControls, hit); } } } }
public void Shoot() { if (gun) { if (coolingDown <= 0) { GunLaserScript gunControls = gun.GetComponent <GunLaserScript> (); gunControls.Shoot(); Vector3 forward = gun.transform.TransformDirection(Vector3.forward); int ShotLength = gunControls.ShotLength; int RayStrength = gunControls.RayStrength; RaycastHit hit; if (Physics.Raycast(transform.position, forward, out hit, ShotLength)) { GunShot(gunControls, hit); } coolingDown = gunCoolDown; } } }