Announcement

Collapse
No announcement yet.

cannot do Blueprint Multiplayer spawn and possess

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

    cannot do Blueprint Multiplayer spawn and possess

    Hello all, I am having problems with letting clients possess pawns with blueprint..
    In fact, I'm trying to mock up World of Warships..

    I look through multiplayer live training's sample, its procedure is like this: set up a sever-run spawn event (lets say it's called "customeventS"), which leads to spawn pawn blueprints, and let different client's player controller posses a pawn.

    Click image for larger version  Name:	mpp2.jpg Views:	1 Size:	219.3 KB ID:	1499592
    Click image for larger version  Name:	mpp3.jpg Views:	1 Size:	436.2 KB ID:	1499590



    In the player controller blueprint, pass its controller instance as controller id to the
    "customeventS". (In this case it is called Respawn Player Event)


    Click image for larger version  Name:	mpp1.JPG Views:	1 Size:	238.6 KB ID:	1499593
    Therefore, if we run 2 clients instance on a computer, each client will trigger the ""customeventS" so they can possess a pawn.
    So this is how I set up for my controller and game mode.
    Put four player start in to the scene


    Click image for larger version  Name:	mppmy1.JPG Views:	2 Size:	306.4 KB ID:	1499594


    In the player controller bp, cast to the custom game mode, and call its server only function
    Click image for larger version  Name:	mppmy2.JPG Views:	2 Size:	223.2 KB ID:	1499595


    In the custom game mode, create the custom server only event, and pass the controller ID to the possess function..
    Click image for larger version  Name:	mppmy3.JPG Views:	1 Size:	260.8 KB ID:	1499586



    But when I hit play, it's like this.....

    Click image for larger version  Name:	mpptest.jpg Views:	1 Size:	238.5 KB ID:	1499599
    Only spawn a default camera at the default position..

    It has the warnings in the log, but I do not understand what do they mean.


    Click image for larger version  Name:	logmpp.jpg Views:	1 Size:	193.8 KB ID:	1499591



    In single player, it is like this....


    Click image for larger version  Name:	mppsingle.jpg Views:	3 Size:	398.3 KB ID:	1499598
    I just set the auto possess then it go through it well, but not in multiplayer...
    Click image for larger version

Name:	image_141917.jpg
Views:	547
Size:	428.2 KB
ID:	1499597


    Am I missing something here? It's so frustrating....
    Attached Files
    Last edited by WildBill16; 07-10-2018, 03:04 AM.

    #2
    I might messed up the logic.
    So when each game instance launched,each client controller will call the get all player start class and spawn and possess four times, and the event play also calls the spawn all player event.

    So I should get rid of the call spawn all player event after the event begin play?

    And then how do I let the client controller choose a player start based on its controller index?

    Comment


      #3
      Click image for larger version  Name:	modify.JPG Views:	1 Size:	271.5 KB ID:	1499609
      But even after I correct this, the problem still occurs..This time the warning info changes.

      Click image for larger version

Name:	modify2.jpg
Views:	547
Size:	178.9 KB
ID:	1499612
      Last edited by WildBill16; 07-10-2018, 03:22 AM.

      Comment


        #4
        Found more clues.
        The two game instance said their controller index is "-1
        Click image for larger version

Name:	playerindex.jpg
Views:	533
Size:	249.4 KB
ID:	1499622
        Attached Files

        Comment


          #5
          First you need to have a clear picture of where the classes exist.

          A GameMode class only exist on the server so if a client try to use GetGameMode nothing is returned.

          A PlayerController only exist on the server and on the client that owns the PlayerController. When a client uses GetPlayerController it will get its own PlayerController. The same is true for a Listen Server.

          A Replicated Pawn exist everywhere.

          Now you need to understand if your flow graph flow is currently running server-side or client-side. Eg. if you try to call a GameMode RunOnServer event from a PlayerController client-side it will fail.
          The GameMode class should not have any RunOnServer events even though some tutorials use this. It is confusing and redundant since it is ONLY the server who can ever call events in the GameMode.

          Client-side in the PlayerController the client first makes a RunOnServer event on the PlayerController to move Server-side. Now the Server can access the GameMode functions. Possess is a server function so when it is done the client should be updated as needed.

          ps. You should always GetPlayerController at index 0 when doing multiplayer online or LAN. The other indices are only used when having several players on the same computer.

          Comment


            #6
            Originally posted by GarnerP57 View Post
            First you need to have a clear picture of where the classes exist.

            A GameMode class only exist on the server so if a client try to use GetGameMode nothing is returned.

            A PlayerController only exist on the server and on the client that owns the PlayerController. When a client uses GetPlayerController it will get its own PlayerController. The same is true for a Listen Server.

            A Replicated Pawn exist everywhere.

            Now you need to understand if your flow graph flow is currently running server-side or client-side. Eg. if you try to call a GameMode RunOnServer event from a PlayerController client-side it will fail.
            The GameMode class should not have any RunOnServer events even though some tutorials use this. It is confusing and redundant since it is ONLY the server who can ever call events in the GameMode.

            Client-side in the PlayerController the client first makes a RunOnServer event on the PlayerController to move Server-side. Now the Server can access the GameMode functions. Possess is a server function so when it is done the client should be updated as needed.

            ps. You should always GetPlayerController at index 0 when doing multiplayer online or LAN. The other indices are only used when having several players on the same computer.
            Hello Garner,
            thanks for the reply.
            I tried to read more tutorials and follow the live training video, and I found that client could get game mode.
            Click image for larger version

Name:	problem1.jpg
Views:	538
Size:	330.3 KB
ID:	1499989
            Click image for larger version

Name:	problem1s.JPG
Views:	550
Size:	232.3 KB
ID:	1499988


            I use a new method to spawn players into new positions, it let the client spawn, however, the client player experience very buggy movement (maybe the client is not even controlling the pawn)
            Click image for larger version

Name:	proble,2.JPG
Views:	553
Size:	254.2 KB
ID:	1499990




            Comment


              #7
              Print String messages in the editor is shown in all windows with a prefix of who actually called the Print String. As you can see it is prefixed with "Server" not "Client1". The GameMode definitely doesn't exist by default on any clients.

              Comment


                #8
                Originally posted by GarnerP57 View Post
                Print String messages in the editor is shown in all windows with a prefix of who actually called the Print String. As you can see it is prefixed with "Server" not "Client1". The GameMode definitely doesn't exist by default on any clients.
                Confirmed..Indeed, the client controller cannot get game mode.
                So the remaining problem is client cannot see server and other client player, and the client is always shaking
                I think the problem is that the authority machine does not that approve so the client pawn's position is set between authority default value and client local value...
                But looks like it cannot explain why client cannot see the server player and other clients...

                Comment


                  #9
                  Your question is about possessing pawns during gameplay as I understand but since you are using PostLogin I can give you a tip on how to manipulate what pawn is spawned on Login.

                  This is a rough overview of the order that GameModeBase handles a new player logging in and spawning its Pawn.
                  The blue colored text is where you can override the behavior through Blueprints.

                  GameModeBase
                  • Login
                    1. Creates a PlayerController for the player
                    2. Initializes the new player
                      1. Register PlayerID in PlayerState
                      2. Register the player in OnlineSession
                  • PostLogin
                  • HandleStartingNewPlayer
                    1. CanRestartPlayer?
                    2. RestartPlayer
                      1. FindPlayerStart
                        • ChoosePlayerStart
                      2. RestartPlayerAtPlayerStart
                        • GetDefaultPawnClassForController
                        • SpawnDefaultPawnFor
                          • SpawnDefaultPawnAtTransform
                  I suggest you disconnect your current PostLogin logic and simply override SpawnDefaultPawnClassForController.
                  Within this function GameModeBase provides a Pawn Class that the new player should spawn with. All you need to do is specify a Pawn Class and return it. You could make an array of possible Pawns and return a random array element or whatever you like.

                  If you don't override this function it simply returns the GameModeBase DefaultPawnClass.
                  Last edited by GarnerP57; 07-11-2018, 11:03 AM.

                  Comment


                    #10
                    Originally posted by GarnerP57 View Post
                    Your question is about possessing pawns during gameplay as I understand but since you are using PostLogin I can give you a tip on how to manipulate what pawn is spawned on Login.

                    This is a rough overview of the order that GameModeBase handles a new player logging in and spawning its Pawn.
                    The blue colored text is where you can override the behavior through Blueprints.

                    GameModeBase
                    • Login
                      1. Creates a PlayerController for the player
                      2. Initializes the new player
                        1. Register PlayerID in PlayerState
                        2. Register the player in OnlineSession
                    • PostLogin
                    • HandleStartingNewPlayer
                      1. CanRestartPlayer?
                      2. RestartPlayer
                        1. FindPlayerStart
                          • ChoosePlayerStart
                        2. RestartPlayerAtPlayerStart
                          • GetDefaultPawnClassForController
                          • SpawnDefaultPawnFor
                            • SpawnDefaultPawnAtTransform
                    I suggest you disconnect your current PostLogin logic and simply override SpawnDefaultPawnClassForController.
                    Within this function GameModeBase provides a Pawn Class that the new player should spawn with. All you need to do is specify a Pawn Class and return it. You could make an array of possible Pawns and return a random array element or whatever you like.

                    If you don't override this function it simply returns the GameModeBase DefaultPawnClass.
                    Hi Thanks for that.
                    That is much better solution for the choices for the player.
                    Last edited by WildBill16; 07-14-2018, 05:46 AM.

                    Comment

                    Working...
                    X