private void Update() { // shoot handling WeaponController activeWeapon = GetActiveWeapon(); if (activeWeapon && weaponSwitchState == WeaponSwitchState.Up) { // handle aiming down sights isAiming = inputHandler.GetAimInputHeld(); // handle shooting bool hasFired = activeWeapon.HandleShootInputs( inputHandler.GetFireInputDown(), inputHandler.FireHeld(), inputHandler.GetFireInputReleased()); // Handle accumulating recoil if (hasFired) { accumulatedRecoil += Vector3.back * activeWeapon.recoilForce; accumulatedRecoil = Vector3.ClampMagnitude(accumulatedRecoil, maxRecoilDistance); } } // weapon switch handling if (!isAiming && (activeWeapon == null || !activeWeapon.isCharging) && (weaponSwitchState == WeaponSwitchState.Up || weaponSwitchState == WeaponSwitchState.Down)) { int switchWeaponInput = inputHandler.GetSwitchWeaponInput(); if (switchWeaponInput != 0) { bool switchUp = switchWeaponInput > 0; SwitchWeapon(switchUp); } else { switchWeaponInput = inputHandler.GetSelectWeaponInput(); if (switchWeaponInput != 0) { if (GetWeaponAtSlotIndex(switchWeaponInput - 1) != null) { SwitchToWeaponIndex(switchWeaponInput - 1); } } } } // Pointing at enemy handling isPointingAtEnemy = false; if (activeWeapon) { if (Physics.Raycast(weaponCamera.transform.position, weaponCamera.transform.forward, out RaycastHit hit, 1000, -1, QueryTriggerInteraction.Ignore)) { if (hit.collider.GetComponentInParent <EnemyController>()) { isPointingAtEnemy = true; } } } }