Announcement

Collapse
No announcement yet.

[Video] Player-Controlled Replicating Physics Movement, Simulating Physics!

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

    [Video] Player-Controlled Replicating Physics Movement, Simulating Physics!

    I have some amazing news!

    ~~~

    Massive Update! ~ Feb 21 2016

    Using a new algorithm that is a hybrid of both input replication and interpolation, I've now accomplished my goal of a game based on replicating player-controlled physics-simulating characters that can also platform freely!

    I can now fully support the network coding for a physics-based platformer multiplayer game!

    You won't believe it but in the video below I am testing with 200 millisecond simulated lag!

    The results are that good!

    I am using a completely custom pawn for this, with my own skeletal mesh component! I am not using ACharacter replication system at all.



    ~~~

    I invented an algorithm that supports replication of the movement of meshes that are player-controlled and simulating physics!

    Replicating the movement of skeletal meshes that are simulating physics is one level of the issue I've been solving,

    but the other level is when that replicated skeletal mesh movement is being controlled by a human player!

    As you might well know from looking in the code base, replicating player-controlled movements over a realistic network situation is quite complicated!

    Well in this video I demonstrate replicating player-controlled movements of physics-simulating skeletal meshes!

    Enjoy!

    ~~~

    Realistic Network Lag

    I used these network settings forth both server and client for realitistic network testing!

    You can stick the below into a .txt in your Engine/Binaries directory and then run it using exec filename.txt from the console of both clients and server.

    Net PktLoss=1
    Net PktOrder=0
    Net PktDup=0
    Net PktLag=75
    Net PktLagVariance=0

    ~~~

    Video

    In the video it looks like I am just rolling around, the reason it is significant is because the movements are replicating properly!

    The right window is the client, who is watching the server move around accurately despite having to watch what the listen server is doing across a network!



    ~~~

    Secret Core of Algorithm

    I dont ever do hard "sets" of the Mesh's physics location, I only apply additional forces on the non-player simulated proxies to keep them up to date with what actual player's mesh is doing!

    So each client and the server are being told what the correct physics mesh location is, but are then just applying additional forces to the replicated linear and angular velocity to get their proxies to the right position.

    The actual player-controlled mesh does not receive any updates so that the player's experience is always smooth, instead the player-controlled mesh is updating all of its proxies over the network.

    ~~~

    What This Means

    This means multiplayer game where all the players are controlling physics simulating skeletal meshes!

    Physics-based multiplayer game!

    Rama

    PS: Epic if you want this tech for ACharacter class, to check when a Character's mesh is ragdolled and then run my code to keep the simulated ragdoll meshes in sync, let me know!
    Last edited by Rama; 02-21-2016, 10:15 PM.
    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

    #2
    This looks great, and very relevant to probably most of my work so far in UE4. (Replicated physics-based movement)
    I'm curious about your "Secret Core of Algorithm"... Does the player have full authority of their own position?
    My implementation has been the client moving their own mesh, but also sending the input so that the server moves it too. Then the client has to trust the server and fix their position every now and then, which is the hard part, as you have to have a good way of fixing their position without rubberbanding.
    I'm not sure how similar it is to yours but I'm interested to hear more

    Also, is that a skeletal mesh? It looks like a static mesh :P
    [Game] Hyper Jam - Neon-soaked arena brawler
    [Plugin] Auto Settings - Game options and input binding toolkit
    [Plugin] [Free] Inline Styling Decorator - Allow inline styling on RichTextBlock

    Comment


      #3
      Originally posted by Acren View Post
      Does the player have full authority of their own position?
      Yup! the local player is in control!



      Originally posted by Acren View Post
      Also, is that a skeletal mesh? It looks like a static mesh :P
      Yes its a skeletal mesh, it has a lot of morph targeting I did not demo in the video

      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


        #4
        Originally posted by Rama View Post
        Yup! the local player is in control!
        Ah. Wouldn't this allow a player to potentially hack and just move however they want? (Disable physics or set their location)
        Or do you have a way to prevent this?

        Originally posted by Rama View Post
        Yes its a skeletal mesh, it has a lot of morph targeting I did not demo in the video
        Nice
        I've also toyed with the idea of replicated ragdolls, though I didn't need mine to be player controlled!
        I haven't got around to trying it in UE4 yet, but I would very much like to get it working eventually.
        [Game] Hyper Jam - Neon-soaked arena brawler
        [Plugin] Auto Settings - Game options and input binding toolkit
        [Plugin] [Free] Inline Styling Decorator - Allow inline styling on RichTextBlock

        Comment


          #5
          Originally posted by Acren View Post
          Ah. Wouldn't this allow a player to potentially hack and just move however they want? (Disable physics or set their location)
          Or do you have a way to prevent this?
          Not sure what you mean by hacking in this context, the player use WASD to move their physics simulating mesh around the level,

          other players have their proxy updated to what the local player is doing with their mesh

          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


            #6
            Ohh great work!

            I'd love to see this integrated in the engine itself! My game too would benefit from replicated ragdolls position (for gameplay reasons too, not only cosmetic).
            Jefferson Pinheiro

            Comment


              #7
              Originally posted by Ixiguis View Post
              Ohh great work!

              I'd love to see this integrated in the engine itself! My game too would benefit from replicated ragdolls position (for gameplay reasons too, not only cosmetic).
              Thanks Ixiguis!

              Oh yea, for your gun that pins people to the wall! Good point

              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


                #8
                Is this, in effect, a dynamic character controller?

                Because that's rad. I love dynamic character controllers.

                Syncing physics objects is a huge paint - this is awesome.
                Last edited by n00854180t; 07-08-2014, 10:55 PM.
                Storyteller - An immersive VR audiobook player

                Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

                Comment


                  #9
                  Originally posted by n00854180t View Post
                  Is this, in effect, a dynamic character controller?

                  Because that's rad. I love dynamic character controllers.
                  What exactly do you mean by dynamic character controller as compared with the regular character controller?

                  Yea syncing physics can be tough, but now that I"ve got it going I can make multiplayer game with a completely physics driven playable character!!



                  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


                    #10
                    Originally posted by Rama View Post
                    Not sure what you mean by hacking in this context, the player use WASD to move their physics simulating mesh around the level,

                    other players have their proxy updated to what the local player is doing with their mesh

                    Rama
                    If you give a player full control of their own position, and that is sent to the server / other clients, a client could potentially hack the game and teleport / move to whatever coordinates they want without any restrictions.

                    http://www.gabrielgambetta.com/fpm1.html

                    http://gafferongames.com/networking-...me-networking/

                    Now at this point you might wonder. Hey, if you are running code on the client – why not just make the client authoritative over their player character? The client could run the simulation code for their own character and simply tell the server where they are each time they send a packet. The problem with this is that if each player were able to simply tell the server “here is my current position” it would be trivially easy to hack the client such that a cheater could instantly dodge the RPG about to hit them, or teleport instantly behind you to shoot you in the back.
                    http://gafferongames.com/game-physic...orked-physics/

                    Client side prediction works by predicting physics ahead locally using the player’s input, simulating ahead without waiting for the server round trip. The server periodically sends corrections to the client which are required to ensure that the client stays in sync with the server physics. At all times the server is authoritative over the physics of the character so even if the client attempts to cheat all they are doing is fooling themselves locally while the server physics remains unaffected. Seeing as all game logic runs on the server according to server physics state, client side movement cheating is basically eliminated.
                    [Game] Hyper Jam - Neon-soaked arena brawler
                    [Plugin] Auto Settings - Game options and input binding toolkit
                    [Plugin] [Free] Inline Styling Decorator - Allow inline styling on RichTextBlock

                    Comment


                      #11
                      Originally posted by Rama View Post
                      What exactly do you mean by dynamic character controller as compared with the regular character controller?

                      Yea syncing physics can be tough, but now that I"ve got it going I can make multiplayer game with a completely physics driven playable character!!



                      Rama
                      The regular character controller, as far as I know, is kinematic. Meaning that physics objects can't push it in the normal way that physics objects get pushed around (it *may* have support for doing that, but if so it's probably done via the kinematic movement system still).

                      I might be wrong though, and maybe it's already using a dynamic character controller? Dunno.

                      The difference is basically whether or not the collision volume is kinematic or dynamic in the physics sim.

                      It's a little hard to explain because UE4 I think fakes a lot of the stuff you don't get normally with a kinematic character controller, such as being able to be pushed, and not having infinite push force yourself etc.
                      Storyteller - An immersive VR audiobook player

                      Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

                      Comment


                        #12
                        Originally posted by Acren View Post
                        If you give a player full control of their own position, and that is sent to the server / other clients, a client could potentially hack the game and teleport / move to whatever coordinates they want without any restrictions.
                        Have you actually started coding in UE4's network code?

                        Epic has protection mechanisms to prevent that.

                        Every server/client function has to be validated in the compile-time code itself or it won't run



                        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


                          #13
                          Originally posted by n00854180t View Post
                          The regular character controller, as far as I know, is kinematic. Meaning that physics objects can't push it in the normal way that physics objects get pushed around (it *may* have support for doing that, but if so it's probably done via the kinematic movement system still).

                          I might be wrong though, and maybe it's already using a dynamic character controller? Dunno.

                          The difference is basically whether or not the collision volume is kinematic or dynamic in the physics sim.

                          It's a little hard to explain because UE4 I think fakes a lot of the stuff you don't get normally with a kinematic character controller, such as being able to be pushed, and not having infinite push force yourself etc.
                          Yes the controller I am showing in video is using full physics, not kinematic animation/movement.

                          That's the whole point of the video and my algorithm!

                          Fully replicating player-controlled physics movement! Yay!



                          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


                            #14
                            Originally posted by Rama View Post
                            Have you actually started coding in UE4's network code?

                            Epic has protection mechanisms to prevent that.

                            Every server/client function has to be validated in the compile-time code itself or it won't run



                            Rama
                            Oh, that's news to me.

                            I've been doing plenty of work with replication and RPCs if that's what you're asking, but haven't heard of anything like this.

                            Do you know anything about these mechanisms or where I can read about them?

                            Thanks
                            [Game] Hyper Jam - Neon-soaked arena brawler
                            [Plugin] Auto Settings - Game options and input binding toolkit
                            [Plugin] [Free] Inline Styling Decorator - Allow inline styling on RichTextBlock

                            Comment


                              #15
                              Originally posted by Acren View Post
                              Oh, that's news to me.

                              I've been doing plenty of work with replication and RPCs if that's what you're asking, but haven't heard of anything like this.

                              Do you know anything about these mechanisms or where I can read about them?

                              Thanks
                              If you look in the C++ at the ShooterGame example you can see how every server function is now marked with WithValidation, and in the CPP you can see how every server/client function must have both _Implementation and _Validate

                              This is what I am talking about

                              Example from my code base

                              Code:
                              bool AJoyMovement::SERVER_SetJoyMove_Validate(EJoyMovement::Type NewJoyMode)
                              {
                              	return true;
                              }
                              
                              void AJoyMovement::SERVER_SetJoyMove_Implementation(EJoyMovement::Type NewJoyMode)
                              {
                              	//Already current?
                              	if(JoyMoveMode == NewJoyMode)
                              	{
                              		return;
                              		//~~~~
                              	}
                              
                              //....
                              Every server/client function must be validated in this way or the UE4 code wont compile



                              Rama
                              Last edited by Rama; 07-09-2014, 09:48 PM.
                              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

                              Working...
                              X