Announcement

Collapse
No announcement yet.

[TEMPLATE] Multiplayer TopDown Template C++

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

    [TEMPLATE] Multiplayer TopDown Template C++

    Hey guys,

    just gaging interest levels. I just finished creating a basic version of the TopDownTemplate but Multiplayer since the original version is not compatible with Multiplayer. Using the same theory as mentioned here: https://answers.unrealengine.com/que...-built-in.html

    It uses AIController Pawns to move your character around and so far works quite nicely.

    If anyone is interested, I will clean and upload to github for everyone. I am not planning on making any money with this. Just helping out as I have been searching like a "crazy" person and finally figured it out after about 2 days of head banging.

    Click the github link below and feel free to extend / use as you see fit.
    GitHub Repo
    Last edited by MegaChill; 12-13-2016, 09:55 AM. Reason: Added github repo

    #2
    Could be useful in the future so subscribed

    Comment


      #3
      I also made a basic multiplayer version of it, simply by running pathfinding stuff on server, and apparently works fine, I had only problem with character rotation replication, but it was easy to resolve. In theory ACharacter features some movement smoothing for network games, but I would be interested in what you created.
      "Age of Total Heroes" - RTS Pathfinding and Movement System for UE4
      RTS Camera C++ Tutorial

      Comment


        #4
        thanks!!!

        Comment


          #5
          Originally posted by sivan View Post
          I also made a basic multiplayer version of it, simply by running pathfinding stuff on server, and apparently works fine, I had only problem with character rotation replication, but it was easy to resolve. In theory ACharacter features some movement smoothing for network games, but I would be interested in what you created.
          I have made it public on github, just check the original post. Rotation etc all is working as it should.

          Comment


            #6
            Will def check this out.
            -------------------------------------------------------------------------------------------------------------------------
            Mitchell 'Panda' Rolland
            FreekVision
            Games. The Way We See Them.
            Team Lead / Game Designer
            -------------------------------------------------------------------------------------------------------------------------

            Comment


              #7
              I don't really understand why it is better than simply in PlayerController do a check on button press IsLocalController() , and if true make ray tracing and target setting locally on client, then call a server function and passing this new location, where you do the pathfinding by NavSys->SimpleMoveToLocation(this, DestLocation);
              by the way, you could add hiding the decal component of the character on BeginPlay() if the controller is not IsLocalController()
              "Age of Total Heroes" - RTS Pathfinding and Movement System for UE4
              RTS Camera C++ Tutorial

              Comment


                #8
                Originally posted by sivan View Post
                I don't really understand why it is better than simply in PlayerController do a check on button press IsLocalController() , and if true make ray tracing and target setting locally on client, then call a server function and passing this new location, where you do the pathfinding by NavSys->SimpleMoveToLocation(this, DestLocation);
                by the way, you could add hiding the decal component of the character on BeginPlay() if the controller is not IsLocalController()
                Like I had said this is ONE way to do it, I didn't say it is the ONLY way to do it. With that being said, it was mentioned multiple times WHY SimpleMoveToLocation was not intended for Multiplayer and should not be used as such. (by Epic Staff btw). However what I wanted to achieve was an architecture where the Player would never host any game but all would come from a dedicated server, and that is what I have achieved, e.g. every player gets his own Character (controlled by AI) to posess and control.

                Here is a Quote from the EPIC Lead AI Programmer on this topic::

                Originally posted by MieszkoZ
                SimpleMoveToLocation was never intended to be used in a network environment. It's simple after all Currently there's no dedicated engine way of making player pawn follow a path. It seems like a feature we should support in the engine, so we'll add it in not too distant future. In the meantime I'd suggest just having an AI controller on the server that PlayerController would send requests to and have all the movement happen on the server.
                So I took what he said at face value and trust in his words. You can also take a look at the thread on answerhuib where people discuss the blueprint and play around with SimpleMoveToLocation etc and they all encounter issues.

                Comment


                  #9
                  Thanks, I think I understand now After reading your description, now I remember I had also problems with SimpleMoveToLocation and player controller controlled pawn, namely player characters are out of the Detour Crowd avoidance system, thus AI characters can get stuck at player characters (no avoidance only collision), and vica versa, what you solved by using AIContoller for the player too. Great!
                  "Age of Total Heroes" - RTS Pathfinding and Movement System for UE4
                  RTS Camera C++ Tutorial

                  Comment


                    #10
                    Originally posted by sivan View Post
                    I also made a basic multiplayer version of it, simply by running pathfinding stuff on server, and apparently works fine, I had only problem with character rotation replication, but it was easy to resolve. In theory ACharacter features some movement smoothing for network games, but I would be interested in what you created.
                    I know this is a (seriously) old thread, but this approach is the same as mine (all pathfinding/movement done on the server). I'm still having trouble with rotation, however. The server works fine (as expected), and every client except the active one shows movement and rotation correctly. For the current client, however, the character moves to the target point without problem but it always faces the top of the map. I am running multiplayer from the editor with three players (server and two clients). When I select a client, its character won't rotate to face the direction of movement, but on the server and the other client, the movement looks like it's supposed to. There must be something in the client code that is overriding the server's direction and not allowing the character to change facing, but I can't find it. Can anyone help?

                    Comment


                      #11
                      I used code from Tom Looman's Survival Game to resolve it, see aicharacter code. Or maybe the Shooter example game. Tomorrow I can check this.
                      "Age of Total Heroes" - RTS Pathfinding and Movement System for UE4
                      RTS Camera C++ Tutorial

                      Comment


                        #12
                        Originally posted by sivan View Post
                        I used code from Tom Looman's Survival Game to resolve it, see aicharacter code. Or maybe the Shooter example game. Tomorrow I can check this.
                        If you could take a look, I'd really appreciate it. I've looked at Tom's code but the answer still eludes me. Thank you.

                        Comment


                          #13
                          @Dijon
                          I'm calling this from AICharacter Tick() function if (Role == ROLE_Authority) as Multicast_SetRotation(GetActorRotation());



                          void AOGWAICharacter::Multicast_SetRotation_Implementation(FRotator NewValue)
                          {
                          LastYawRotation = FMath::Abs(FMath::UnwindDegrees((NewValue.Yaw) - (GetActorRotation().Yaw)));

                          SetActorRotation(NewValue.Quaternion());
                          }
                          "Age of Total Heroes" - RTS Pathfinding and Movement System for UE4
                          RTS Camera C++ Tutorial

                          Comment


                            #14
                            sivan
                            Thank you very much for the help. I'm curious, however, if you've missed a step. You calculate LastYawRotation, which is a float, but don't do anything with it and instead use NewValue that is passed to the function. Am I missing something obvious?

                            Comment


                              #15
                              Hi,

                              I just used your template but I have some very bad issues
                              In the editor looks great don't have any problem and it's smooth. But if I run it outside of editor with built dedicated server and client connected to that it's very choppy.
                              See : https://www.youtube.com/watch?v=PuZk...ature=youtu.be

                              Do you have any idea how I can fix it ? Or this solution is just not correct ?
                              Many thanks for help.

                              Comment

                              Working...
                              X