void PlayerPressedStart(InputAction.CallbackContext value) { //check for max amount of players if (m_ControllerIds.Count == m_MaxPlayers) { Debug.Log("The maximum amount of players has already been reached."); } else { //check if controller is already used if (m_ControllerIds.Contains(m_GameInputControls.MenuControls.Start.activeControl.device.deviceId)) { Debug.Log("Device is already assigned to a player"); } //add a player else { InputDevice controller = m_GameInputControls.MenuControls.Start.activeControl.device; m_ControllerIds.Add(controller.deviceId); //setup the controls and user Controls gameInputControls = new Controls(); gameInputControls.MenuControls.Enable(); //we start in a menu InputUser user = InputUser.PerformPairingWithDevice(m_GameInputControls.MenuControls.Start.activeControl.device); user.AssociateActionsWithUser(gameInputControls); //spawn the player object and initiate it properly GameObject menu = Instantiate(m_SelectionMenu, m_MainLayout.transform); InputBehaviour inputBeh = menu.GetComponentInChildren <InputBehaviour>(); if (inputBeh != null) { inputBeh.SetInputUser(user, controller); inputBeh.RumbleController(0.8f, 0.66f); } CharacterSelection characterSelection = menu.GetComponentInChildren <CharacterSelection>(); if (characterSelection != null) { characterSelection.SetPlayerIndex(m_PlayerId); m_PlayerSelections.Add(characterSelection); } //set player id to the charactercontrol inputBeh.gameObject.GetComponent <CharacterControl>().PlayerId = m_PlayerId; //save the camera m_Cameras[m_PlayerId] = menu.GetComponentInChildren <Camera>(); //inc playerid ++m_PlayerId; //this setup has to be after the increment (has to do with the actual player numbers and not their spot in an array which starts at 0) SetupCameras(); Debug.Log("Player " + m_PlayerId + "joinend!"); } } if (m_PlayerId == 4) { m_HelpText.SetActive(false); } }