// Spread calculation currentSpread = Mathf.Min(maxSpread, currentSpread + spreadPerShot); Vector3 spreadOffset = Random.insideUnitSphere * currentSpread;
[Header("Recoil & Spread")] public float recoilForce = 2.5f; public float maxSpread = 5f; public float spreadPerShot = 0.5f; private float currentSpread = 0f; private float spreadDecayRate = 20f; // per second
She studied how actual weapons behave: recoil that kicks the camera up, spread that increases with sustained fire, and ammo that doesn’t magically refill on reload.
using UnityEngine; public class RealisticGun : MonoBehaviour { [Header("Weapon Stats")] public float damage = 35f; public float range = 100f; public float fireRate = 600f; // rounds per minute public int magazineSize = 30; public int currentAmmo; public float reloadTime = 2.5f; private bool isReloading = false;