Announcement

Collapse
No announcement yet.

Multiplayer Topdown-Game - Navmesh won't be replicated to clients?

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

    Multiplayer Topdown-Game - Navmesh won't be replicated to clients?

    Hi,

    I'm working on a little multiplayer game and to get into the topic I watched this tutorial series (which is by the way very nice): Unreal Engine 4 Networking

    This series gave me some basic knowledge and I'm currently trying to setup a multiplayer mode for my own game. My game is based on the top down template where you can simply click on the floor to make your character run to the clickposition. I did a quick setup by deleting the character from the scene and adding 2 player start locations to the scene instead. After that I set the "Number of players" to "2" in the play options:

    Click image for larger version

Name:	01.jpg
Views:	1
Size:	50.5 KB
ID:	1155987

    Then I started the game. Unfortunately it's not possible to move the player character on the client but it works on the server (left: server, right: client)

    Click image for larger version

Name:	02.jpg
Views:	1
Size:	58.4 KB
ID:	1155988

    To make sure that the input of player 2 gets handled correctly, I added a simple option to rotate the camera with simple key presses (by pressing spacebar the camera rotates until space is released) and this works for both players (or: server + client).

    So by knowing that the inputs work in general, I guess that the navmesh is not replicated for player 2 but I can't find an option to do this Does someone know a solution for this?

    Thanks and best regards,
    Daniel
    Daniel Mihajlovic |Freelance 3D Artist | Showreel

    #2
    The SimpleWalkToX just works with an AI controller on multiplayer games.
    Free Inventory System (BP AND C++ Version): Clicky Clicky
    Player Structure System (Houses!) (BP): Pew Pew Marketplace Version: Yoink!
    Howto: Create Dragable UMG Windows: Zoom Zoom

    Comment


      #3
      Have a look at this topic at answerhub: https://answers.unrealengine.com/que...-built-in.html
      FinalCamera on Marketplace / Web Demo
      TopDown Toolkit on Marketplace / Web Demo

      Comment


        #4
        Thanks for your help, guys!

        I'm quite confused why unreal doesn't support this feature by default. The solution from the other thread obviously seems to work (altough i didn't test it by myself) but it is - as the author stated - a very hacky way to achieve a solution for a relatively simple task.
        Building the character controls in such a hacky way may lead to unpredictable problems in the further development steps of a game and I'm not sure if that's a solid foundation for a "real game". So is there a cleaner way to get things done?

        Don't get me wrong - I'm happy that there IS actually a solution for this issue but it's not ideal as the author himself stated and there must be a better way to do this (I mean we're talking about the Unreal Engine and not about some c-class tool ;D)

        Best regards,
        Daniel
        Daniel Mihajlovic |Freelance 3D Artist | Showreel

        Comment


          #5
          Here's what I've got so far

          Hi,

          I'm trying to setup a similar approach to solve the problem but there are some problems. It works in a single player game but there are some errors in the multiplayer version. So to summarize the main idea:

          - The player is represented by a default pawn that only contains a spring arm and a camera
          - the player controller spawns an AI-player (which contains the model and all the animations and is the visual representation of the player), an AI controller for the AI-player, which feeds the blackboard of the AI-player with all necessary data (for example a click location that is used as a "move to" target in the behavior tree)
          - the player controller sets the player's pawns position (or in other words: the player's camera) to the AI-player's position so that your camera always follows your player model

          Here you can see a visual version of the theory and the blueprint of the player controller:

          Click image for larger version

Name:	logic.jpg
Views:	1
Size:	169.7 KB
ID:	1082422

          Click image for larger version

Name:	03_playercontroller_a.jpg
Views:	1
Size:	289.9 KB
ID:	1082423
          Click image for larger version

Name:	03_playercontroller_b.jpg
Views:	1
Size:	237.8 KB
ID:	1082424
          Click image for larger version

Name:	03_playercontroller_c.jpg
Views:	1
Size:	134.3 KB
ID:	1082425


          This works as expected in the single player version and the model moves to the click location properly.
          If i start a simulated multiplayer game in the editor, two players get spawned:

          Click image for larger version

Name:	02_multiplayer.jpg
Views:	1
Size:	174.3 KB
ID:	1082426

          BUT only the server's player can be controlled and the log window shows these error messages caused by the client:

          Click image for larger version

Name:	02_error.jpg
Views:	1
Size:	284.5 KB
ID:	1082427

          Do you have any idea why it doesn't work in a multiplayer game? In the single player version there are no errors in the log or anything else which is really strange (by the way: the replication properties of each class are left to the default settings)

          Thanks and best regards,
          Daniel
          Daniel Mihajlovic |Freelance 3D Artist | Showreel

          Comment


            #6
            Check out pallys series Unreal Engine 4 RTS Series Part 1 The Camera: https://youtu.be/uhbMEBMTJKU

            Comment


              #7
              Thought I'll add a few cents. Definitely on the right track. The reason why it doesn't work in multiplayer is because AIController only exists on the server. Was just helping another guy on reddit/r/unrealengine regarding a similar issue with click and move for multiplayer. Spent a bit of time making a rough tutorial on it. (About 16 mins long, definitely could be better edited, and presented)
              Demonstration: https://www.youtube.com/watch?v=sWr1cvOyZYU
              Tutorial: https://www.youtube.com/watch?v=vNjxEdMYSCI (16 min rough draft)

              Comment


                #8
                Hi Tinyted,

                thanks for your videos! They're really helpful and I think it's a good start for many of the users out there with similar problems.

                I've managaed to get things done and the controls work for server and client but I've encountered a slight stuttering on the client side while everything works fine on the server side.
                My input is setup like in epic's top down template where you affect the character's movement as long as you hold down LMB so that the character follows your cursor. This works without any delay on the server but you can see that the character's movement is not perfectly smooth on the client.
                I guess this has something to do with the navigation function that is executed on the server. Maybe this step leads to a little delay which is unfortunately noticeable?

                The movement of the character gets smoother by increasing the replication rate per second in the Blueprint from default 100 to 2000 but even with such a high value the movement on the client side is not 100% smooth and you can still see some stuttering.
                I also tried to use different movement nodes in the AI controller (Move to Location, AI Move to, Simple Move to) but this makes no difference.

                My game is based on a smooth and fast gameplay and I need to get rid of that slight stutter effect for an optimal gaming experience. So if you have any ideas how to improve the character movement on the client, please let me know

                @twinnaz06: Thanks for the link! This was also very useful to understand how to setup such controls in general

                Thank you and best regards,
                Daniel
                Daniel Mihajlovic |Freelance 3D Artist | Showreel

                Comment


                  #9
                  Hey Polygon, would you happen to be able to get a video of that stuttering? And the related blueprint.

                  Does the stuttering happen whenever you change the cursor position while holding it down. Or does just the fact that holding it down in one spot already creates a stuttering effect.

                  I've seen some really weird slow movement if you just take the Top-Down template, and let the server perform the simple move to location that it uses. I'm not sure if that's the stuttering effect you're talking about, or if it's something else. My own pet project isn't an RTS style like gameplay, so I actually haven't played around with a lot of the move to nodes. (Only happened to make the tutorial because I saw someone having issues with it, and gave a quick try to see if I could solve the issue)

                  EDIT: Just did a quick test to implement a Hold down RMB to move, and think I may have found the potential cause of your issue.
                  Last edited by Tinyted; 07-26-2015, 12:09 PM.

                  Comment


                    #10
                    Quick follow up in regards to the Hold down to move issue.
                    (Video for those that prefer video: https://youtu.be/RoU-mFDLlZ4, it's absolutely unedited, since I just did it in a rush)

                    The reason for the stuttering is because the Server has an instance of all player controllers. Thus if you don't check if the instance is a local controller, the server will execute things for the client also. And if the server doesn't have the cursor information, or the mouse held down info, it's going to stop the movement. So what ends up happening is:
                    CLIENT: MOVE!
                    SERVER: STOP!
                    and you get a back and forth of stuttering.
                    Increasing replication rate, if I'm not mistaken actually increases the time between each replication. Thus decreasing the move and stop cycle, and making it "smoother".

                    The simple solution is to check if the controller is a local one, if it is, then execute the relevant code in stopping or moving. (You still have to tell the server to stop and move).

                    Comment


                      #11
                      Thank you very much for your help, Tinyted!

                      I will upload a video and screenshots of my blueprints this evening as soon as I'm back from work. Your theory sounds plausible to me and I'm really looking forward for your feedback on my upcoming uploads

                      Best regards,
                      Daniel
                      Daniel Mihajlovic |Freelance 3D Artist | Showreel

                      Comment


                        #12
                        I finally managed to gather all the needed information and here we go

                        So the logic is like this:

                        1. Custom Game Mode sets "PlayerPresence" (Pawn that only contains a camera component) as the default pawn and also sets "PlayerMobaController" as the default player controller

                        2. "PlayerPresence" spawns an AIcharacter (the model with all the animation stuff on it) and an AIcontroller that does the via a simple Move to Location node

                        3. PlayerMobaController receives input, the server does the movement and the PlayerPresence follows the AI's position

                        In the following video you can see the stuttering effect on the right (client) side while the server's AI character moves totally smooth:

                        http://www.polyflow.de/temp/stutterissue.mp4

                        And here are the blueprints:

                        Click image for larger version

Name:	01_playerpresence.jpg
Views:	1
Size:	343.5 KB
ID:	1082638
                        Click image for larger version

Name:	02_playercontroller.jpg
Views:	1
Size:	320.6 KB
ID:	1082639
                        Click image for larger version

Name:	03_playerAIcontroller.jpg
Views:	1
Size:	101.4 KB
ID:	1082640

                        I'm not sure but I think it might be that is has something to do with the camera alignment and that the stuttering is not in the AI movement itself. I've played around a little bit and tried different versions with a lerp, without a lerp, with a spring arm, with spring arm delay, etc.. but the issue is still noticeable, no matter which way I try

                        So hopefully you have an idea

                        Thanks and best regards,
                        Daniel
                        Last edited by polygon; 07-27-2015, 05:35 PM.
                        Daniel Mihajlovic |Freelance 3D Artist | Showreel

                        Comment


                          #13
                          Hi,

                          I've done some more testing and it's not related to the camera movement. the AI character seems to move slightly edgy and blocky on the client. I'm not sure why the movement on the server is smooth while it's not on the client but I could imagine that it's somehow related to the fact that the movement is done on the server and maybe this causes some kind of very subtile (but noticeable) delay in the calculation of the AI position/animation?

                          The problem gets worse if I decrease the "Replication Rate" in the Character's defaults from default 100 to lower values like 20 or even 5 so I guess it's somehow related to this rate. Unfortunately the problem can't be avoided by increasing this value from 100 to higher values, which totally doesn't make any sense to me.

                          It's horrible to be this close to the goal and then struggling with such a small but extremely annoying problem.

                          By the way: I tried also the check if the controller/player is local like tinyted mentioned in his latest video but this had no effect

                          Best regards,
                          Daniel
                          Daniel Mihajlovic |Freelance 3D Artist | Showreel

                          Comment


                            #14
                            Hello,


                            I had this problem and fixed it. To describe the issue; in dedicated, the owning client would falsely predict his own movements and get the forced network update RPC producing a jitter movement without correct rotation.

                            The simple solution is to enable client navmesh in your project settings and to call move to on the owning client and server only.. (see image)

                            I have provided a paste that you can put in your ThirdPerson character template project and see it working.

                            https://pastebin.com/MuxHeYQr

                            Press T to navigate to the spot in the middle of the screen.

                            This is not a great solution, but it will get you moving.

                            Comment

                            Working...
                            X