protected override void PrimaryFire() { RaycastHit hit; Quaternion fireRotation = Quaternion.LookRotation(transform.forward); Quaternion ranRot = Random.rotation; /* ### \/ Bullet Spread( Different When Aiming ) \/ ### */ if (!isAiming) { fireRotation = Quaternion.RotateTowards(fireRotation, ranRot, Random.Range(0f, hipSpreadAngle)); } else { fireRotation = Quaternion.RotateTowards(fireRotation, ranRot, Random.Range(0f, aimSpreadAngle)); } /* ### \/ Muzzle Flash Stuff \/ ### */ audioSource.PlayOneShot(primaryFireSound); muzzleFlash.Play(true); if (Physics.Raycast(muzzle.position, fireRotation * Vector3.forward, out hit, maxRaycastDist)) { /* ### \/ Damage && Physics Stuff \/ ### */ ViewController vc = hit.transform.GetComponent <ViewController>(); DamageHandler dh = hit.transform.GetComponent <DamageHandler>(); Rigidbody rb = hit.transform.GetComponent <Rigidbody>(); AddWeaponForceAtPoint(rb, hit.point); if (NetworkManager.instance != null && vc != null && dh != null) { int id = vc.connectionID; DealNetworkedDamage(id, (damage * dh.damageMultiplier)); } else if (dh != null) { dh.Damage(damage); } /* ### \/ Hit Impact Effects \/ ### */ Transform t = Instantiate(Game.instance.GetImpactFromTag(hit.transform.tag)).transform; t.position = hit.point; t.LookAt(transform); return; } Projectile p = Instantiate(projectile.prefab, muzzle.position, muzzle.rotation).GetComponent <Projectile>(); p.damage = damage; p.hitCallback = HitCallback; p.rigidbody.AddForce(transform.forward * fireForce, ForceMode.Impulse); }
protected override void PrimaryFire() { RaycastHit hit; Quaternion fireRotation = Quaternion.LookRotation(transform.forward); audioSource.PlayOneShot(primaryFireSound); muzzleFlash.Play(true); if (Physics.Raycast(muzzle.position, muzzle.forward, out hit, maxRaycastDist)) { /* ### \/ Damage && Physics Stuff \/ ### */ ViewController vc = hit.transform.GetComponent <ViewController>(); DamageHandler dh = hit.transform.GetComponent <DamageHandler>(); Rigidbody rb = hit.transform.GetComponent <Rigidbody>(); if (NetworkManager.instance != null && vc != null && dh != null) { int id = vc.connectionID; DealNetworkedDamage(id, (damage * dh.damageMultiplier)); } else if (dh != null) { dh.Damage(damage); } /* ### \/ Hit Impact Effects \/ ### */ if (NetworkManager.instance != null) { ClientTCP.SpawnRegisteredPrefab(Game.GetSlugFromTag(hit.transform.tag), hit.point, Quaternion.identity); } else { SpawnImpactEffect(hit.transform.tag, hit.point); } return; } Projectile p = Instantiate(projectile.prefab, muzzle.position, muzzle.rotation).GetComponent <Projectile>(); p.damage = damage; p.hitCallback = HitCallback; p.rigidbody.AddForce(transform.forward * fireForce, ForceMode.Impulse); }