Perhaps, I haven’t renamed some of the code properly. I’m not sure as I tried this soon after you posted your code and I can’t remember what was wrong (this was my first time making changes in C++ as well so there could be many things I might have done wrong). I think I was getting errors and could not compile the new code. Thank you though, I will post here once I get back to this.
I still have many other things to do in the meantime and I keep having weird bugs since I moved to 5.3 so there is no shortage of things to fix for me!
I finally understand what you mean with bug reports I’ll see what happens once I start submitting mine! It kinda sucks that the tickets are actually filtered…
I’m surprised how responsive you both are. That’s awesome
Just FYI to anyone reading this, you also need to include “ApplicationCore”, “Slate”, “SlateCore”, “EngineSettings”, “EnhancedInput” dependency to your Build.cs file in order for it to be linked.
You’ll need to create a new C++ class inheriting from GameViewportClient, copy the code I posted into the header/cpp file (renaming it to match your class name etc), and set that as your viewport class in project settings.
If you’re not familiar with C++ you’ll probably want to watch a few tutorials on that, and those instructions will make sense.
I’ve tried this and hooked up some print nodes to debug. The print nodes come out just fine, but I still can’t get it to work. Think you could make a detailed explanation?
Greetings!
I found a way to make the local multiplayer work. I am on 5.3 and the problem persisted.
I followed this guide but still it would not work, the 2nd controller does not respond:
Now, what I did was the following:
In the thirdpersoncharacter blueprint, after the Event beginPlay
node, the next node I put is a Delay node of 0,1 second. And it worked.
I am not entirely sure why but I think what is happening is that the enhanced input local player subsytem is activating before the other players are created, and thus they receive no mapping context at the time of their creation. With a delay of 0,1 (or any other delay), I think the other players are created first and then given a mapping context.
Confirming that this bug is still present in UE 5.3. Any news of a bug report or fix in the works for this? It’s a pretty frustrating issue and seems like it would be easy to fix.
Nice to see that it’s finally fixed. Shame it took them over a year and they never acknowledged any of the bug reports, but that seems pretty standard for Epic these days.
Can someone help me? I’ve been trying to find a solution by reading this forum, trying out the methods presented, watching videos, and getting help from Discord, but I’m still stuck.
I created a Local Player with the Controller ID being 1.
I added Mapping Context with the Local Player as the Target.
I possessed my character using the created Player Controller.
The inputs don’t work when PlayerController_0 is being used either.
(The blueprint is in my GameMode)
Problem: My inputs don’t work and I can’t move my character. Any help would be appreciated!
It took me 6 days for something so simple!! I overcomplicated the whole thing because for my game I didn’t even need to use multiplayer and create a local player. I just used the Player Controller with index 0, two different Mapping Contexts, and Inputs, then I called them and checked my Player Variables if P1 = 1 or P2 = 2 to execute the movement. I’m so relieved right now.
Hey guys. So it seems the solution for the “Skip Assigning Gamepad to Player 1” will be fixed in 5.4.
If you are in 5.3 and don’t want to mess with the C++ code or you have a BP only project, here you have a Plugin that I made that implements the exactly same fix that will be in 5.4.
It will only work on Windows and UE 5.3 but you can compile it for your platform yourself.
Unzip and add it to your project in the Plugins folder.
Open the Project (Enable the plugin GameViewportLocalMultiplayer) and go to Project Settings - Game Viewport Client Class and replace the current vlaue with the CommonGameViewportMultiplayer.
Restart and Done
BTW: This will work with Common UI Projects so this Plugin inherits from Common UI Game Viewport. Just in case
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.
Thanks so much @schuan - that worked!! Please let me know where I can send you money for a coffee! Everyone else, @schuan 's plugin was the solution for us as it worked in Unreal Engine 5.3.2, enabling us to have one player on keyboard and one using an Xbox controller in local co-op.