x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Screenshot

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.

Screenshot2

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

Product Version: Not Selected
Tags:
more ▼

asked Oct 22 '14 at 07:39 PM in Blueprint Scripting

avatar image

zerofiftyone
204 26 28 93

avatar image AlaaEltayeb Nov 17 '14 at 01:48 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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 );

more ▼

answered Oct 23 '14 at 12:55 PM

avatar image

mkamradt
294 15 136 34

avatar image zerofiftyone Oct 23 '14 at 02:01 PM

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

avatar image L4g0 Aug 15 '18 at 06:29 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Dec 05 '14 at 09:59 AM

avatar image

esquire
36 5 10 17

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 27 '15 at 09:19 PM

avatar image

Lich120
1

avatar image mkamradt Apr 28 '15 at 07:54 AM

:-) 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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question