Our team did the upgrade to 5.4 and while this specific issue is sort of fixed, the whole ‘Platform User’ system seems to have broken a lot of other stuff. Part of this might be me misunderstanding the system, but as usual Epic have not documented any of their changes, so it’s hard to be sure.
Right now, my game is working like this:
- In the GameInstance, on init, run ‘CreateLocalPlayerForPlatformUser’ until it doesn’t return a valid PlayerController
- This is because we want to listen to some kind of ‘join’ button event from the player, e.g. the lobby screen
- If you don’t do this then you only get one player controller, and the Keyboard and Gamepad both get assigned to it - the bug is only partially fixed, if only one player controller exists it will ignore this setting and assign the gamepad to the same player
- In the GameInstance, bind to the OnInputDeviceConnectionChange event
- This is a new event that finally exposes when an input device connects/disconnects to Blueprints (it was in C++, Epic just didn’t expose it for reasons)
- When a new device is connected, ensure it has a player controller
- When a device disconnects, get it’s player controller (GetLocalPlayerControllerFromPlatformUser), and tell it to unpossess it’s pawn
At first this appears to work, when I ‘join’ on my keyboard I get one player, and when I join on my gamepad I get another. But if I disconnect my controller, the keyboard player gets unpossessed.
On my player controllers, I hooked up a print statement to the possess event to show ‘GetPlatformUserId’ - when I join on my keyboard it shows ID ‘0’, and on my gamepad it’s platform user ID ‘1’. But when my controller disconnects ‘OnInputDeviceConnectionChange’ reports that platform user ID ‘0’ has disconnected…which is the keyboard.
The comment for ‘GetPrimaryPlatformUser’ suggests that ‘0’ is the default for things like a keyboard and mouse which don’t get assigned a unique ID. But it looks like the first gamepad connected also gets this ID, so we’re back to square one where ‘Skip assigning gamepad to player 1’ doesn’t apply to platform user IDs.
My current workaround looks like this: