Hi,
I’m trying to create a local coop menu in which when a device button is pressed a player prefab is instantiated and the device is assigned to his PlayerInput component. BUT…it doesn’t work since it looks like the PlayerInput component has no assigned devices.
private void Awake()
{
playerControls = new PlayerControls();
playerControls.MenuPlayersRegistration.Register.performed += ctx =>
InstantiatePlayer(ctx.control.device);
}
void InstantiatePlayer(InputDevice newDevice)
{
PlayerInput playerInput = PlayerInput.Instantiate(playerPrefab, PlayersNumber, "Gamepad",
PlayersNumber, newDevice);
Debug.Log("Player " + playerInput.playerIndex);
foreach (InputDevice i in playerInput.devices)
{
Debug.Log(i.deviceId + "/n");
}
PlayersNumber++;
}
When I debug playerInput after the Instantiation it shows the devices list empty and also an hasMissingRequiredDevices field.