// Update is called once per frame void Update() { // Only react to scroll wheel if players can switch team. if (!CanSwitchTeam) { return; } float currentScroll = _input.GetMouseScroll(); if (Mathf.Abs(_oldScrollValue - currentScroll) >= ScrollDifference) { if (_oldScrollValue > currentScroll) { --CurrentTeam; } else { ++CurrentTeam; } // Infinite scrolling if (CurrentTeam < 0) { CurrentTeam = AmountOfTeams - 1; } else if (CurrentTeam >= AmountOfTeams) { CurrentTeam = 0; } _oldScrollValue = currentScroll; UpdateColor(); } }