UMG and multiple controllers

Hey all,

I’m in the process of building a menu system for my game, and so far I have most of the work done; the menu is basically a player ready screen for a local multiplayer game I’m making.

Each player joins the game by pressing A on their gamepad, and can optionally back out by pressing B once joined. Here’s the blueprint script I’m using to grab the controller input.

The problem is this:
The gamepad input only works for player one at the moment. I must be missing something somewhere, but I can’t work out what I’m doing incorrectly.

Does anybody have any experience with this or any clue as to the problem I’m having?

Thanks for reading,

Ben

I have not done any new research with UE 4.5 but with UE 4.4 you would not get any controller input if no player had been created to use that controller.

So the only way was to subclass UGameViewportClient in C++ and override the InputKey() method where all input is routed to.

See the snippet to demonstrate the usage below.

Marc

if( EventType == IE_Released
	&& ( Key == EKeys::Gamepad_Special_Right ) || ( Key == EKeys::SpaceBar ) )
{
	// join or leave?
	ULocalPlayer* localPlayer = GEngine->GetLocalPlayerFromControllerId( GetWorld(), ControllerId );

	if( localPlayer == nullptr )
	{
		UGameplayStatics::CreatePlayer( this, ControllerId, true );

		return true;
	}
	else if( localPlayer != nullptr )
	{
		// leave
		GEngine->GetWorldContextFromWorldChecked( GetWorld() ).OwningGameInstance->RemoveLocalPlayer( localPlayer );

		return true;
	}
}

return Super::InputKey( Viewport, ControllerId, Key, EventType, AmountDepressed, bGamepad );

Yeah that’s the same in 4.5; I should add that I have already created players for each controller.

A few hours ago I managed to figure out a workaround for this using event dispatchers. It works well enough and can tide me over until 4.6 arrives with its gamepad support.

Thanks for your time

Ben

am trying to do a similar thing here so did u get anywhere with this ??

Ben,

I’m trying to achieve the same sort of results, is there anyway you can post a screen shot of your blueprint with the event dispatchers. 4.6 didn’t really seem to resolve this as far as I can tell.

Thanks,

John.

Hey guys, I may be a bit late to the party but I noticed I was still having this problem in 4.7.6 and this was one of the questions I came across while trying to find a solution. I too was trying to have the “Press A to join” system for local players.

The issue I was experiencing is when Keyboard Focus is set, only player 1 (index 0) would be able to interact with the menu. All other game input was being blocked. I even tried the overriding of GameViewport input but the input from the other three controllers never made it there. We’ll I found a solution that worked for me after investigating what “Set Focus Keyboard” was doing.

Set Keyboard Focus only sets the focus for the User at index 0 as it just calls SetUserFocus() and passes in GetUserIndexForKeyboard(). Since SetUserFocus isn’t a blueprint function, I added my own UserWidget class and made it the parent of my Main Menu. In there I added a function “SetUserFocus” that takes a UserId and then calls: FSlateApplication::Get().SetUserFocus(UserId, SafeWidget);

I made it blueprint callable and just call it on all my Controllers when I load the UMG.

Hopefully this will help anyone else who’s having this problem as I was banging my head against the wall for some time.

:slight_smile: More information here, since I just found out that local coop did not anymore work after upgrading to 4.7.5: https://answers.unrealengine.com/questions/218443/475-cannot-process-input-events-of-additional-game.html

This method still works for 4.19 and I recommend it. It saved me a lot of work.

Any chance to see in detail how it works? Already spent one week and my gamepad is still assigned to Player Controller 0

Hi Arfeus. This thread is from six years ago so unfortunately I don’t remember the situation any more, nor do I have my hands on the project I was working on back then.
I hope you find what you’re looking for — good luck and sorry I couldn’t be of help.