Announcement

Collapse
No announcement yet.

Keyboard = p1 gamepad = p2 please!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I think the feature just isn't there (user friendly version). On my end I checked answer hub, documentation and forums and had no luck. The only was apparently is to edit code or add code. I have 0 C++ knowledge. So having it in the engine via settings or something would be cool to have.
    Available for Freelance (Concept Art/Illustration) - Visit my Portfolio

    Comment


      #17
      I posted a tutorial with various local multiplayer tips, and one of them is how to allow the keyboard for the 1st player and the controller for the 2nd player: https://wiki.unrealengine.com/Local_Multiplayer_Tips

      Unfortunately, the only way to do the keyboard/controller split right now is via C++ code. It's a bit hacky, but it works for now. I think my instructions are possible to follow with even just minimal C++ coding experience.

      I do agree that it should be a default feature. The way I could see a "proper" implementation is:
      • If the game detects more players than gamepads, the keyboard/mouse is mapped to player 0, and the first controller is mapped to player 1, the second to player two, etc. This behavior could potentially be enabled or disabled by a checkbox, if someone really likes it the current way
      • If the game detects gamepads >= num players, then it's the current behavior where the keyboard/mouse and the first controller is player 0, the second controller is player 1, etc.


      Unfortunately, as far as I can tell the engine currently does not have a way of querying the number of gamepads connected, and each platform handles gamepad detection separately. So it would take a bit of work to get it working, though I don't think it would be that hard. If I have time, I'll take a shot at making this change and putting a pull request to get the feature added to the engine, but it's going to be a little while before I can get to it.

      Comment


        #18
        Wow. I was bashing my head against the wall for 6+ hours over this, thinking it was me. Now this really irritates me, haha!

        Comment


          #19
          I would also love this feature! I would love to be able to use the keyboard for one player and a controller for a second player. Officially supported.

          Comment


            #20
            This really would be helpful. i can only assume this affects all local mp games at the moment.

            Comment


              #21
              Why has no one from Epic even looked into this yet after all these months?!? I mean this affects pretty much every local Co Op game made with UE4.
              Having to spend so much time to come up with a blueprint setup for such a simple task makes me sad.

              Comment


                #22
                I'm waiting to see this feature as well in the next releases, hopefully Epic sees this thread.
                Available for Freelance (Concept Art/Illustration) - Visit my Portfolio

                Comment


                  #23
                  I tried to come up with a solution for this. But I just can't see a way to make the first player (controller) "give up" the inputs of the first gamepad and pass it on to the second player (controller) in blueprints.
                  Is there any progress on this huge problem yet?

                  Comment


                    #24
                    Thanks, it works well, very usefull.

                    Comment


                      #25
                      Originally posted by XilenceX View Post
                      I tried to come up with a solution for this. But I just can't see a way to make the first player (controller) "give up" the inputs of the first gamepad and pass it on to the second player (controller) in blueprints.
                      Is there any progress on this huge problem yet?
                      To do a dirty hacky keyboard/controller or keyboard/keyboard way you'll have to setup duplicate inputs, one for player 1, the other for player 2.

                      e.g. Player1Up, Player2Up

                      These all get picked up from player 1's player controller class, then you just send the input to the correct pawn.

                      Comment


                        #26
                        Can I bump this thread? This really needs to be looked at again! Would be over the moon happy if they implemented a fix for this. Right now, I have a two player split screen game that I want to build + compile but I cant possibly send it out until there's a fix for this.

                        Comment


                          #27
                          I am bumping this because i think that after 14 new releases this should've been addressed already.

                          Comment


                            #28
                            [MENTION=33015]sonicphi[/MENTION] Actually, I think they have addressed this and forgot to tell anybody. At least, I read all of the 4.13 release notes and don't recall seeing it mentioned.

                            Look at the bottom-right option in this screenshot from my current project in 4.13:

                            Attached Files

                            Comment


                              #29
                              Haha that's funny, but ye it does look like they forgot.

                              But still it feel a bit incomplete, the process to create coop be it on the key board only ( 2 players on the keyboard ) or game pad only ( game pads ) seems a bit clunky still.
                              What if i want my player 1 to be on the game pad and player 2 to be on the keyboard?

                              Imo they should add something like the input setup, where you can "add" players and specify if u want them on the keyboard, mouse or game pads.

                              With this it seems player 1 will always be forced to be on the keyboard no?

                              Comment


                                #30
                                Hello there!

                                After searching a lot, I finally found a solution by talking to MordenTral (awesome dude and author of two amazing plugins). Basically, the clean solution to achieve this is to create a child class of UGameViewportClient which overrides InputKey(...) and InputAxis(...). In the overrides, you can reroute where certain inputs go and both functions have bool bGamepad as a parameter so you can basically use that to determine where you want to send the input. It is necessary to set the Game Viewport Client Class in Project Settings to be the newly created class. You can make this class blueprintable and expose an Enum UPROPERTY to Blueprint so that you can actually create a child blueprint class and can change behavior dynamically at runtime using blueprints (of course the Game Viewport Client Class in Project Settings would need to point to this blueprint class).

                                Here is the answer on AnswrHub: https://answers.unrealengine.com/que...#answer-779572

                                Here is my UCustomGameViewportClient class:

                                #pragma once

                                #include "CoreMinimal.h"
                                #include "Engine/GameViewportClient.h"
                                #include "CustomGameViewportClient.generated.h"

                                /** This class introduces a new Input-PlayerController binding behaviour. Through the EGameInputMethod Enum it is possible to choose the default
                                * behavior (in which keyboard/mouse input and gamepad input are both binded to Player 1 [index 0]) or the Player1OnlyKeyboardAndMouse behavior
                                * (in which keyboard/mouse input is binded to Player 1 [index 0] and gamepad input is shifted to the other players).
                                */
                                UENUM(Blueprintable)
                                enum class EGameInputMethod : uint8
                                {
                                GameInput_Default,
                                GameInput_Player1OnlyKeyboardAndMouse,
                                };

                                UCLASS(Blueprintable)
                                class SIDESCROLLER_API UCustomGameViewportClient : public UGameViewportClient
                                {
                                GENERATED_BODY()

                                public:

                                // Input Method for the viewport
                                UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Input")
                                EGameInputMethod GameInputMethod;


                                virtual bool InputKey(FViewport* tViewport, int32 ControllerId, FKey Key, EInputEvent EventType, float AmountDepressed = 1.f, bool bGamepad = false) override
                                {
                                if (GameInputMethod == EGameInputMethod::GameInput_Default)
                                return Super::InputKey(tViewport, ControllerId, Key, EventType, AmountDepressed, bGamepad);

                                if (GameInputMethod == EGameInputMethod::GameInput_Player1OnlyKeyboardAndMouse && bGamepad)
                                {
                                // shift gamepad input to controllers with +1 index
                                ++ControllerId;
                                return Super::InputKey(tViewport, ControllerId, Key, EventType, AmountDepressed, bGamepad);
                                }
                                else
                                {
                                return Super::InputKey(tViewport, ControllerId, Key, EventType, AmountDepressed, bGamepad);
                                }
                                }

                                virtual bool InputAxis(FViewport* tViewport, int32 ControllerId, FKey Key, float Delta, float DeltaTime, int32 NumSamples = 1, bool bGamepad = false) override
                                {
                                if (GameInputMethod == EGameInputMethod::GameInput_Default)
                                return Super::InputAxis(tViewport, ControllerId, Key, Delta, DeltaTime, NumSamples, bGamepad);

                                if (GameInputMethod == EGameInputMethod::GameInput_Player1OnlyKeyboardAndMouse && bGamepad)
                                {
                                // shift gamepad input to controllers with +1 index
                                ++ControllerId;
                                return Super::InputAxis(tViewport, ControllerId, Key, Delta, DeltaTime, NumSamples, bGamepad);
                                }
                                else
                                {
                                return Super::InputAxis(tViewport, ControllerId, Key, Delta, DeltaTime, NumSamples, bGamepad);
                                }
                                }


                                };


                                Create Blueprint class from this, and you'll see ou can change the Enum to whatever you like.

                                To change this at runtime you'll need to access this class with UWorld::GetGameViewport(), so make a function in a c++ blueprint function library (if you want to have access via Blueprints):

                                class UGameViewportClient* FunctionLibrary::GetGameViewport(const UObject* WorldContextObject)
                                {
                                UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
                                return World ? World->GetGameViewport() : nullptr;
                                }

                                Once you have that exposed, all you need to do is cast it to your custom Game Viewport class and set the enum to the desired value.

                                I must say that this works perfectly for me... but I also have input on UI and in that case, it isn't working, I still need to find out what happens in that case.

                                Comment

                                Working...
                                X