We are currently adding a local multiplayer mode to our online multiplayer game. While the replication works fine, we experience some strange behaviour concerning the input modes:
Whenever we change the Input Mode of one of the local players (in its player controller blueprint), the Input Mode is changed for the other local players as well. Examples:
When a new local player drops in and its input mode is initially set to “UI Only”, the other players on this PC loose their input for the game. (Means, their input mode is changed as well)
When there are multiple local players and one finishes the current round, his input is so far set to “UI Only” in order to allow him to look at the scores and so on. But at this moment, the other (local!) players again also get changed to “UI only” and can´t play anymore…
However, from the documentation of the respective nodes (Set input mode to Game Only, UI Only, Game and UI), I had thought, the input mode is to be set separately for each player controller. Or am I mistaken here?
There should be a suitable workaround by using only the “Set Input Mode to Game and UI” and setting Widgets in focus or none widget, but I still would be curious if there is not another solution…
We need to see the blueprint to pinpoint the problem. I am doing splitscreen and can have some players moving their pawns around while others are in the menus.
I don’t know if that’s because I have a more complicated menu logic that uses “Game and UI” mode and masks out certain actions depending on certain flags being set, or if it’s because I connected the specific player controller to the Set Input Mode node.
Rather old questions, but let me answer this for you all:
InputMode is NOT separately set per player. InputMode is set per Viewport. So in this case the GameViewport.
So if you have 2 or more local players and you have one of them opening a menu, you CAN’T set the InputMode to “UIOnly”, because that effects the other players, that need Game Input, too.
In this case you need to use “GameAndUI” as InputMode.
I did not know that. I was wondering why through trial and error that I had to use GameAndUI mode all the time on my splitscreen project when I wanted players to be able to summon menus individually. That requirement causes me to have to add branches and gates to my BP code to tell the PlayerController to keep inputs that are meant for the menus from being processed by the Pawn and moving it around.
It would make things much simpler if the whole viewport was either paused and in-menu for all local players or not, but I designed my game differently from that so I have to deal with the complications that causes.
And in case you run 2 windows on the same machine (i.e. - play in editor with 2+ players)?
after changing the input mode in begin play, the main window is in focus but the second window receives the input
I have found when running 2+ instances on the same machine, that all instances receive gamepad input (so it appears that gamepads don’t focus instances).
In fact, I Was running a web browser which takes gamepad input (Flappy Bird) while running my project as a desktop app (totally different game) and pressing fire made my tank shoot a bullet in my project, and made the bird flap in the web browser.