Player CreatePlayer(InputDevice inputDevice) { if (players.Count == 0) { // Pop a position off the list. We'll add it back if the player is removed. // Create a new instance and specifically set it to listen to the // given input device (joystick). var actions = MyCharacterActions.CreateDefaultBindings(); actions.Device = inputDevice; player1.GetComponent <Player>().Actions = actions; players.Add(player1.GetComponent <Player>()); p1_entered.SetActive(true); return(player1.GetComponent <Player>()); } else if (players.Count == 1) { var actions = MyCharacterActions.CreateDefaultBindings(); actions.Device = inputDevice; player2.GetComponent <Player>().Actions = actions; players.Add(player2.GetComponent <Player>()); p2_entered.SetActive(true); return(player2.GetComponent <Player>()); } return(null); }
void OnEnable() { InputManager.OnDeviceDetached += OnDeviceDetached; joystickListener = MyCharacterActions.CreateDefaultBindings(); }