#Local multiplayer : keyboard and the mouse as the same input device

1 messages · Page 1 of 1 (latest)

stone path
#

Hello everyone,

I've a first scene for the players choose a color and a second scene for the players fight.
In the first Scene I use the following line of script for when a player validate the color he choosed, the following line in "SetPlayerController" function add the controller device in a _playerController dictionary :

_playerController.Add(index, controller.devices[0]);

In the second scene I use the following line to reconnect the player input with the good character :

player1 = PlayerInput.Instantiate(_playerPrefab, player.Key, playerControlScheme, -1, playerController);

But the first line is causing my issue :
if a player joins the game using the keyboard in the first scene, he can move with the keyboard and look in the direction where the mouse is pointing because in his "Player input" Component, there is on the line "devices ": Devices = Keyboard;Mouse. Then in second scene, the same player can reuse this same keyboard to play in the second scene BUT no longer with the mouse because we only gave him the controller.devices[0] and not the controller.devices[1]. And in the second scene on the "device" line there is actually only the keyboard "Devices = Keyboard" If the player, in the first scene, joins the game using the mouse, the devices line becomes Devices = Mouse;Keyboard. So in the first scene nothing changes (the player can use the keyboard and mouse). But in the second scene, this player only has Mouse in the Devices row so he can no longer move, only look at where the mouse is pointing.
I've tried :

player1 = PlayerInput.Instantiate(_playerPrefab, player.Key, playerControlScheme, -1, Keyboard.current, Mouse.current);
or
player1.SwitchCurrentControlScheme("Keyboard&Mouse", Keyboard.current, Mouse.current);

but didn't work.

In Unity Editor my control scheme has "Keyboard" and "Mouse" selected

Can Someone help me to add the Mouse.current in the devices attribute of the player if controlScheme is "Keyboard&Mouse" ?

#

The dictionnary variable is :
public static Dictionary<int, InputDevice> _playerController = new Dictionary<int,InputDevice>();

So I've tried
public static Dictionary<int, List<InputDevice>> _playerController = new Dictionary<int,List<InputDevice>>();
But it didn't solved my issue, two player are spawning one with the keyboard control and the second one with the mouse but not a single player with the two controller :/