public void SwitchWeapon(int slotIndex) { if (slotIndex == currentWeaponSlot) { return; } if (CurrentWeapon != null) { // hide the weapon HideWeapon(CurrentWeapon); } if (slotIndex >= 0) { CurrentWeapon = weapons [slotIndex]; // show the weapon if (CurrentWeapon != null) { UnHideWeapon(CurrentWeapon); } } else { CurrentWeapon = null; } currentWeaponSlot = slotIndex; m_frameWhenSwitchedWeapon = Time.frameCount; m_ped.StopFiring(); this.UpdateWeaponTransform(); }