public void Switch(int direction) { if (direction == 0) { return; } if (Guns.Count <= 1) { return; } if (EquippedGun == null) { EquippedGun = Guns [0]; EquippedGun.OnEquip(gameObject); EquippedGun.equipped = true; return; } EquippedGun.equipped = false; EquippedGun.OnUnequip(gameObject); // Oh my god % is not actually modulo. Why would you do this C#??? //EquippedGun = Guns [(Guns.IndexOf(EquippedGun)+direction)%Guns.Count]; EquippedGun = Guns [(int)Helper.fmod(Guns.IndexOf(EquippedGun) + direction, Guns.Count)]; EquippedGun.OnEquip(gameObject); EquippedGun.equipped = true; }