private void Update() { //if weapon is null we don't want to keep doing weapon related stuff if (PauseMenu.isPaused || weapon == null || PlayerUIScript.IsInEconomyMenu) { return; } shooting = Input.GetKey(primaryAction); tryReload = Input.GetKeyDown(reload); if (tryReload && !reloading && currentAmmo < weapon.ammo && isLocalPlayer) { StartReload(); } else if (reloading) { reloadTime += Time.deltaTime; if (reloadTime >= weapon.timeToReload) { FinishReload(); } } if (shooting && timeSinceLastShot != 0) { motor.AddShootingMotionX(new Vector3(0, weapon.kickDir.x * weapon.settleAmount * -1, 0)); motor.AddShootingMotionY(weapon.kickDir.y * weapon.settleAmount * -1); } if (shooting && !reloading && timeSinceLastShot == 0 && currentAmmo > 0) { motor.AddShootingMotionX(new Vector3(0, weapon.kickDir.x, 0)); motor.AddShootingMotionY(weapon.kickDir.y); Shoot(); } else if (!shooting || currentAmmo == 0 || reloading) { if (sprayIndex != 0) { spraySettleTime += Time.deltaTime; if (spraySettleTime > weapon.settleTime) { sprayIndex = sprayIndex <= 0 ? 0 : sprayIndex - 1; spraySettleTime = 0; } } motor.AddShootingMotionX(Vector3.zero); motor.AddShootingMotionY(0); } timeSinceLastShot -= Time.deltaTime; timeSinceLastShot = timeSinceLastShot <= 0 ? 0 : timeSinceLastShot; }