Announcement

Collapse
No announcement yet.

Come Learn Blueprint Multiplayer with me! (aka Tom's a Glutton for Punishment)

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

  • #31
    Congrats on finally taking the dive into Replication Tom!

    I knew you and replication had a future together!

    See?

    Now you are leading the pack!



    Rama
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

    Comment


    • #32
      This is awesome, thank you posting this. I'm having an issue with the blueprint. I'm trying to add the ChoosePlayerStart into my own game, but I can't get a ReturnNode. I'm new at this and if anyone could point me into the right direction that would be wonderful. Thanks.

      Comment


      • #33
        Never mind, I figured out. You have to click on the function within the graph and add an output, just in-case anyone else gets stuck on this.

        Comment


        • #34
          Success!!



          First off: Thanks, everybody! I'm happy that this thread is getting people into thinking about the fine points of Blueprint multiplayer. I'm sorry for not updating sooner. I've been really busy and completely stumped. A bad combo. I was having a huge headache figuring out exactly what client, server, etc. was calling any given function and, more importantly, why.

          Fortunately, Epic posted some AWESOME videos on Blueprint networking. If you haven't seen them... SEE THEM NOW!
          There's a couple hours worth, but they REALLY clearly explain everything from replication to the various ways Blueprints can send and receive data from servers.
          https://www.youtube.com/playlist?lis...t4chjhypxIO9ZB

          Thank you Epic for providing such awesome learning resources. I'm blown away. The things people will be creating with UE4 will push gaming far and fast.

          Now, for the good news:
          I've got replicating, physics-based actors playing in multiplayer. Both with a dedicated server and a listen server. I haven't tested outside of the editor, but that's gonna happen tomorrow. I'm writing up a post now, but wanted to let y'all know that there's been progress and that it's GOOD.

          Here's a little preview:


          And, here's the project files for those that just can't wait to take a look!:
          https://dl.dropboxusercontent.com/u/...P_20140415.zip

          I'll be back tomorrow with the full breakdown!

          Comment


          • #35
            Originally posted by JamesG View Post
            We are working on some materials that should really help people get to grips with networking, BP and C++!
            The videos were a revelation! I was starting to grasp the basic tenants of replication, but seeing them in a simple example was massively important. I'm impressed that even the advanced topics like relevancy were covered.

            For those that haven't seen them:
            https://www.youtube.com/playlist?lis...t4chjhypxIO9ZB

            Comment


            • #36
              Originally posted by Rama View Post
              Congrats on finally taking the dive into Replication Tom!

              I knew you and replication had a future together!

              See?

              Now you are leading the pack!



              Rama
              Yeah, buddy! your crazy, rainbow-hued replication inspired me! Thanks for the encouragement.

              Comment


              • #37
                Tom, you are awesome, and Epic is also awesome, see that tutorial series clears a lot things up.

                Edit:I also have something half baked, which does not rely on DefaultPawn's movement component and does not have to use the physics part of Pawn class.
                Ideally, there should be a switch to do first person/third person, and a switch to use the physics(move by adding force to set velocity) or just purely roll your own movement(you would have to handle collision response.)

                So far, I can do most of the movement part in later mode, with rotation left to tweak(heavily referencing how the Input example do to the UFO.)
                And Tom's example for 6-DOF tutorial, but you know what, control is indeed a major part of the game, get the feel right needs a lot work.

                Also, I think Tom's player start method can be improved, so you no longer have to rely on a tag( which potentially restrict how many player can spawn on a map, or when Pawn died you used up all respawn point.),
                as I mentioned before, I intended to spawn in a volume, but I haven't get to how to default spawn to a spectator pawn and then possess a player pawn with possibility to choose team. I'll do that once the rotation part is done.
                Last edited by PenguinTD; 04-16-2014, 12:17 PM.
                Unreal Engine 4 Game Framework diagram for relation of all major base object types
                Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                Resident Evil Classic Camera
                RPCs official document, Must Read
                Everything you should know about replication

                Comment


                • #38
                  How to train your pawn to replicate!

                  Hello all. I'm back and I've got all kinds of stuff to share. I'll be posting here, then once everybody's had a chance to take a look and give it a go, I'll publish a nice tutorial to the Wiki.

                  Thanks to all who contributed. I'm absolutely shocked how well this works and how much fun it is to play with a frend or two in a game you've greated, even if it's absurdly simply liek this.

                  What's been done
                  • The 6-DOF pawn I built HERE has been made to fully replicate. Physics and movement are handled completely on the server.
                  • A simple attack has been made (Blast Attack!) that uses a physics impulse to blast other pawns away from the player.
                  • Tested on LAN and it's very fun :F


                  Letting the server do it all

                  One of the first big problems I was having is that when Physics Enabled was set to true on the Pawn, there was some really wacky behavior. What other clients would see and what the player would see were quite different. The player would rotate a little and stop, meanwhile, the other clients would watch as the player's representation would continue to rotate as if pushed by physics. If the pawn were on the ground, it would even roll about. Meanwhile, the player's view was totally still, until they moved, then each of the clients would correct for a moment before returning to their physics drift.

                  Thanks to the videos posted by Ben earlier this week, I was able to understand that what I was seeing was the server replicating physics and sending that data to the clients while the local player was seeing the result of their input only.

                  My solution was bold, but has fixed my issues and allowed me to quickly expand the functionality beyond my original goals!

                  How it's done:

                  Server-Only Physics:
                  I turned off physics COMPLETELY on the local clients. That means that only the server would be doing those calculations. this little line of Blueprint has changed everything for this test:


                  Sending input to the server to handle:
                  Now, I just had to make Custom events that replicated from the Client to the Server each time there was input from the player:


                  And, then do the actions I wanted to the pawn on the server. Each of these custom actions is set to Run on Server and has the Reliable box checked. I figure that input should definitely be replicated reliably, and should be a very small packet to send as I'm only sending the input value:


                  Getting the data back from the server to the payer:
                  At this point, everything was working really well... At least on all the remote clients. My arrows were zipping all over! However, my local player wasn't moving at all. I'm assuming that because player input generally isn't handled remotely, the optimized Replicate movement propoerty of pawns doesn't bother. So, I made my own!

                  After struggling with the jerky, un-smooth replication of position and rotation, I tried replicating the entire transform of my pawn pack to the player. Smooth as butter! I know that this is a very expensive operation, especially at high frame rates, but it's pretty essential for the player to have smooth, fast input. I'll experiment with reducing this workload, but for now this works:


                  And, that's it! That makes it all work! Seriously. Here's the entire Pawn's Event Graph (The fancy Blast Attack is there in green. I'll cover that next)


                  And, here's video of it doing its thang (Sorry about the low frame rate, it runs MUCH faster and smoother locally)!


                  SOURCE FILES:
                  And, here's the project files as of the recording of this video:
                  https://dl.dropboxusercontent.com/u/...P_20140417.zip
                  Last edited by Tom Shannon; 04-20-2014, 09:22 AM.

                  Comment


                  • #39
                    Originally posted by PenguinTD View Post
                    Tom, you are awesome, and Epic is also awesome, see that tutorial series clears a lot things up.

                    Edit:I also have something half baked, which does not rely on DefaultPawn's movement component and does not have to use the physics part of Pawn class.
                    Ideally, there should be a switch to do first person/third person, and a switch to use the physics(move by adding force to set velocity) or just purely roll your own movement(you would have to handle collision response.)

                    So far, I can do most of the movement part in later mode, with rotation left to tweak(heavily referencing how the Input example do to the UFO.)
                    And Tom's example for 6-DOF tutorial, but you know what, control is indeed a major part of the game, get the feel right needs a lot work.

                    Also, I think Tom's player start method can be improved, so you no longer have to rely on a tag( which potentially restrict how many player can spawn on a map, or when Pawn died you used up all respawn point.),
                    as I mentioned before, I intended to spawn in a volume, but I haven't get to how to default spawn to a spectator pawn and then possess a player pawn with possibility to choose team. I'll do that once the rotation part is done.
                    Take a look at my new post above. that should get you up to speed with the movement replication. Its still relies on the built-in replication to get the position and rotation to the other clients, but you'll see how that all works, I think.

                    I've also been thinking about the player start issue. My system works fairly well for a racing game, where the player will always want to spawn in an ordered location and only ever once per match (unlike deathmatch for example.) I was thinking of doing a Get all Actors-> Pawn within a certain distance of each player start to see if they are valid, rather than relying on the tag system.

                    Comment


                    • #40
                      I kinda get the system down as well, albeit looks different from yours, I don't know if it's correct(edit: by correct I mean I merge input event flow that could have some sort of conflict, but all my control feels fine no interlocking at all, maybe James or other Epic guys could tell us if this is a good/bad approach), but here is what I have for replicated movement.

                      **EDIT**: Please note that my control does not use any physics simulation at all, and will go through everything even if my pawn is set to block all. It is because I force update actor location without checking hit event.(I don't even know if you don't simulate physics, will hit event ever emit.) I know we shouldn't reinventing wheels, but this is for study purpose for me, so use at your own risk.

                      Here is my pawn setup, that "Use Controller View Rotation" option almost drive me nuts, after check that off all the camera behavior was solved.


                      Here is the part to handle movement related input


                      Here is OnRep called when force vector is set


                      Here is torque input and OnRep Torque



                      And finally, the part doing update and some debug input to do a break(I haven't implement damping yet.)


                      And here is the result(spawn still using Tom's method, but use teleport):
                      Last edited by PenguinTD; 04-18-2014, 02:55 PM.
                      Unreal Engine 4 Game Framework diagram for relation of all major base object types
                      Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                      Resident Evil Classic Camera
                      RPCs official document, Must Read
                      Everything you should know about replication

                      Comment


                      • #41
                        Penguin, good work. I like the combined force vector idea. I was wondering if you were getting any actual movement? I ask because as far as I know, the Authority (Server-side) Pawn won't be receiving input (Well, maybe it would on a listen server?). As far as I could figure, that only happens with client-side Pawns. So when you use the Authority switch to guard your inputs, you are effectively stopping them from happening. This is also why I don't bother putting the Authority guard on my inputs.

                        Second, and something that's less important but might be of concern: Rep-Notify events only happen AFTER the frame has finished, whereas RPC calls are called immediately. For input, this can have an effect on latency, however I'd assume that ping and network latency would have a far greater effect. This can also cause some issues with things that happen very quickly (Less than a frame), as only the value at the end of the frame is considered, and if it hasn't changed since the previous frame, the rep-notify won't fire as the variable won't have changed.
                        [Quote][/img]
                        Last edited by Tom Shannon; 04-19-2014, 07:17 PM.

                        Comment


                        • #42
                          Yes, as you said once I try to do dedicated server, everything broken. LOL
                          I haven't fully fixed it yet, but your info on RepNotify/RPC is very helpful for me to fix my input events.
                          Currently I'm working on to get network traffic to only replicate function call that apply force or torque, and multicast so all three side would run it.
                          But somehow it doesn't seems to work, I need to study your graph more carefully.
                          Unreal Engine 4 Game Framework diagram for relation of all major base object types
                          Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                          Resident Evil Classic Camera
                          RPCs official document, Must Read
                          Everything you should know about replication

                          Comment


                          • #43
                            I thought so, and I bet on a Listen server, it only worked for Player 1.
                            From what I can tell, in your case you'd just want to move the player locally and let the Replicate Movement checkbox do its magic. This would update to the clients and the server alike. I'm thinking that you're just overcomplicating it (Pot calling the kettle black!) I'll give it a try tonight if I can and report back.

                            Comment


                            • #44
                              YEEEEEES!!!!! Mix bag your RPC call and some tweak on my own(and referencing the UFO on input example content) it's super smooth just relying on the replicated movement. I'm excited!! HAHA!!!
                              It's so simple that I couldn't believe it.(after going through that many set/get/replicate/repNotify/etc.)
                              I'll organize my graph a bit and post a update later. It's so simple I felt like I am an idiot trying to roll my own movement.
                              (The fact that if you really want to roll your own movement, you'd have to hook up physics side yourself, which defeats our purpose for getting a MP_BP_Pawn ready to go without coding. )
                              Unreal Engine 4 Game Framework diagram for relation of all major base object types
                              Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                              Resident Evil Classic Camera
                              RPCs official document, Must Read
                              Everything you should know about replication

                              Comment


                              • #45
                                How do you create a physics material, to setup things like friction/bounciness/mass scale/etc.
                                Right click on empty space in asset browser.


                                Actual Pawn component setup. Root component is a static mesh, and here is the physics attributes.
                                This only shows up after you add a staticmesh component and select it.
                                Note that I set damping attributes to 1 so my pawn stops pretty quick after I release the input,
                                you can adjust those base on how fast you want your momentum to continue working.


                                Pawn replication defaults setup.


                                How to create a custom event (NOT EventDispatcher)
                                Right click on empty blueprint space without dragging any pin.


                                After create custom event, make sure you do this like Tom did. Input rpc run from owning client and replicate to server.
                                EDIT: do NOT check "reliable" checkbox, it was my early mistake when learning, so most of the time you don't need this on.
                                please refer to this article for when you should use reliable RPC call.

                                http://wiki.beyondunreal.com/Everyth...29#Reliability


                                Here is my modified torque input handling.


                                Here is my modified force input handling


                                And here is the actual update that happens on server.
                                Note that forceScale I have is 10,000 and torqueScale is 50,000.
                                You can have other values, but if you didn't have a multiplier, it will be really slow to see any update.
                                Edit: it would be better to have a maximum check on the input vectors as well to prevent "speed" cheating.
                                Where you can just get the vector length and make sure it's not larger than a certain magnitude.



                                Big thanks to Tom and Epic.
                                Now moving onto volume spawning!
                                Last edited by PenguinTD; 09-10-2014, 08:21 PM. Reason: correct my error in the past.
                                Unreal Engine 4 Game Framework diagram for relation of all major base object types
                                Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                                Resident Evil Classic Camera
                                RPCs official document, Must Read
                                Everything you should know about replication

                                Comment

                                Working...
                                X