Realistic Guns -fps Shooter- Script Pastebin -
if (Physics.Raycast(ray, out hit, range)) { // Apply damage to enemy if it has Health script EnemyHealth enemy = hit.transform.GetComponent<EnemyHealth>(); if (enemy != null) { enemy.TakeDamage(damage); }
// Spread calculation currentSpread = Mathf.Min(maxSpread, currentSpread + spreadPerShot); Vector3 spreadOffset = Random.insideUnitSphere * currentSpread; Realistic Guns -fps Shooter- Script Pastebin
private float nextTimeToFire = 0f; private float originalCameraY; if (Physics
// Spawn impact effect Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); } if (enemy != null) { enemy.TakeDamage(damage)