Announcement

Collapse
No announcement yet.

Why is some of the Input handled in ACharacter?

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

    Why is some of the Input handled in ACharacter?

    Why is some of the Input handled in ACharacter? (e.g. MoveForward)

    Shouldn't it all be handled in APlayerController?

    #2
    There, some information on player controller and where to implement stuff.
    https://answers.unrealengine.com/que...ontroller.html
    https://forums.unrealengine.com/show...roller&p=15637
    Alone: The Untold - a story driven horror game

    Comment


      #3
      I understand the concept of the controller, which is what led me to my question. Shouldn't all of the input be handled in the controller?

      My character class (MyProjectNameCharacter) seems to be listening to input - SetupPlayerInputComponent. Why not listen to it only in the controller?

      It seems like in the second link you attached Jeff Farris brought up the same point:

      1) It's fine to handle input in the Character. It's a natural way to think of things, especially for less complex cases, so we made sure to support it. If you have more complex needs though, like multiple players on one game client or the ability to change characters dynamically at runtime, you might be better off keeping your input in the PlayerController.
      2) I've typically followed a marionette-style model, where the PlayerController decides what to do and just issues commands to the Pawn (e.g. "start crouching", "jump")
      That's why I'm surprised that by default some stuff are being listened to in the Character rather than in the PlayerController, unless it's a symbolic piece of code to show it is supported like he mentioned.

      Either that or I'm missing something.
      Last edited by RoyiBernthal; 04-13-2014, 07:54 AM.

      Comment


        #4
        Originally posted by RoyiBernthal View Post
        I understand the concept of the controller, which is what led me to my question. Shouldn't all of the input be handled in the controller?

        My character class (MyProjectNameCharacter) seems to be listening to input - SetupPlayerInputComponent. Why not listen to it only in the controller?
        Well you obviously didnt read what BiggestSmile's linked there.
        Here you go
        Input should be processed in pawn directly.

        For example you have character pawn, vehicle pawn, and helicopter pawn. Controls may and may not differ for every pawn, but still you do various stuff on input triggers.

        So for example character is default pawn, if you enter vehicle, all you'll have to do is change possessed pawn to this vehicle and nothing else, input then will be processed accordingly.

        Comment


          #5
          Everything depends on your final goal, if you're developing a MMO with ability to change pawns during gameplay, like entering vehicle/helicopter/whatever, it would be better for you to implement input processing directly in pawns, if you're developing simple single player game, you're most likely to implement input processing in player controller.

          Myself i implement pawn-related input in pawns, and player-related input, which does not depend on selected pawn, in player controller.
          Last edited by BiggestSmile; 04-13-2014, 08:04 AM.
          Alone: The Untold - a story driven horror game

          Comment


            #6
            Please read my edit as well, seems like we posted at about the same time.

            My bad I didn't read all they way down, could you please help me understand what are "input triggers" and why they are needed? Why not have the input in controller and from there initiate the matching action in the pawn? I'm not entirely sure I understood his example.

            Comment


              #7
              On input triggers i meant "process" when player does some action(presses button, moves mouse).

              You're totally free to do it how you want, but it would be logical to implement input that depends on selected pawn in pawns and so on, read my edit above.

              Just a little edit:
              If you're going to have multiple types of pawns in game and going to implement input in player controller, you'll have to get pawn controller currently posses, then cast it to corresponding pawn or check if it's subclass of some spawn, and only then start processing input. If you implement pawn-related input directly in pawn, you would not need to do all of that, input will be processed automatically.
              Last edited by BiggestSmile; 04-13-2014, 08:10 AM.
              Alone: The Untold - a story driven horror game

              Comment


                #8
                Yes I didnt see your edit when I posted.Like BiggestSmile stated,if you dont have more than a single pawn in your game,you dont need to process input inside Pawn.But if your game has a lot of pawns,each pawn may need to have different inputs,like vehicles.Then you need to check which pawn is possesed in your player controller and switch input processing accordingly,which is hell of a work.The best way to deal with this is if you have more than 1 pawn,input processing should be done inside Pawns.

                Comment


                  #9
                  I guess it's logical if that input is only related to that specific kind of Pawn, which isn't the case with what they did in MyProjectNameCharacter. (If I understood you correctly)

                  I'm developing a single player game, also with the ability to change pawns. Why would it be better to implement input processing directly in pawns in MMOs?

                  Comment


                    #10
                    Read my post closely please, it's all there, and i didn't state it being just some MMO..
                    Alone: The Untold - a story driven horror game

                    Comment


                      #11
                      I think I understood you, so MMO was just a scenario in which different pawns with different inputs may be needed. Right?

                      Comment


                        #12
                        Originally posted by BiggestSmile View Post
                        Everything depends on your final goal, if you're developing a MMO with ability to change pawns during gameplay, like entering vehicle/helicopter/whatever, it would be better for you to implement input processing directly in pawns, if you're developing simple single player game, you're most likely to implement input processing in player controller.

                        Myself i implement pawn-related input in pawns, and player-related input, which does not depend on selected pawn, in player controller.
                        I think this is generally a good model. It's normal to have some input handling that isn't pawn-specific which makes sense to handle in PlayerController. e.g. Handling the Pause key or having Esc bring up the ingame menu -- you don't want to have to duplicate those bindings in every possessable pawn type.

                        One thing I want to point out about the architecture is that all input flow happens through the PlayerController, since input devices are tied to a particular player. This means the PlayerController is the dominant object in terms of input handling. By default, it chooses to recognize the bindings for certain other Actors (possessed pawn, level script), but it has the final authority over where input goes and in what priority order.
                        Senior Engine Programmer, UE4, Epic Games
                        Twitter:
                        @Byooler

                        Comment

                        Working...
                        X