Announcement

Collapse
No announcement yet.

Smooth Sync: Sync your Transforms Smoothly across the network

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

    #16
    Kris
    Ah, I see. I'm still conflicted on if I want to sync to server automatically when there is no owner but I'll definitely look into it.

    I just tested NetCullDistanceSquared and it does not receive messages if they are passed the limit when using unrealiable RPCs.
    Last edited by fuestrine; 07-25-2018, 01:36 PM.
    Sync your transforms Smoothly across the network.

    Comment


      #17
      Originally posted by fuestrine View Post
      I just tested NetCullDistanceSquared and it does not receive messages if they are passed the limit when using unrealiable RPCs.
      Thank you for sharing that.
      It is something I did not know and will hopefully come in handy for others

      Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.

      Comment


        #18
        Are you going to support 4.20?

        Comment


          #19
          iCode
          Good idea. I was starting small so as to have fewer chances at issues. I'll put out some versions that aren't 4.19 in the next few days, including 4.20.

          I'll message you when 4.20 is up on the store.
          Last edited by fuestrine; 07-26-2018, 11:02 AM.
          Sync your transforms Smoothly across the network.

          Comment


            #20
            Something isn't adding up.

            Lets say there is a ball that players can walk into and it gets kicked around. This ball needs an owner for RPCs.

            If there is 3 players, and the server sets a player as the owner, that owner replicates to all players and that player now owns the ball. That player can call RPCs. The rest can't. That's useless because they all need to sync it.

            You can't use RPCs for a system like this, it needs to be purely replication based. Even if you can multicast, you shouldn't, it's more bandwidth intensive and doesn't get called as something becomes relevant like replication does.

            Also.. stuff lying around in the world, where you'd likely actually use this, isn't owned. That's the point.
            Last edited by Vaei; 08-03-2018, 09:10 AM.

            Comment


              #21
              Vaei
              If there is 3 players, and the server sets a player as the owner, that owner replicates to all players and that player now owns the ball. That player can call RPCs. The rest can't. That's useless because they all need to sync it.
              The rest don't need to call an RPC. The owner needs to send an RPC of the transform to the server (possible because of ownership). The server then needs to send out the position to all clients (possible because it's the server). I recognize that the server is then sending back to the owner though.

              doesn't get called as something becomes relevant like replication does.
              Unreliable RPCs take NetCullDistanceSquared into account. If you mean something else for relevancy, let me know and I can test anything you might be questioning.

              it needs to be purely replication based
              Can you have the client change variables and have it replicate out to the server and all other clients? I thought it was purely server controlled.

              Also.. stuff lying around in the world, where you'd likely actually use this, isn't owned. That's the point.
              That's why I have a "SetOwnerToServer" variable, so the user doesn't need to do anything extra for that. I do understand that multi-cast can send from server to clients regardless of ownership though. I'll think about automatically making the server control the position, but I liked the explicit nature of having to set up server ownership so that the user knows exactly who is controlling the position. It seems common to just have the server control the position in Unreal when there is no owner though so I might implement it in the next update.

              Let me know if I misunderstood anything or if you have more questions. Cheers.
              Last edited by fuestrine; 08-03-2018, 01:42 PM.
              Sync your transforms Smoothly across the network.

              Comment


                #22
                The most important thing here is that servers do not own objects. Servers have authority over objects. Actors own objects. If you set PlayerControllerB to the owner, then PlayerControllerB owns that object - not the server, and PlayerControllerA and PlayerControllerC can not call RPCs and can not send the information that would otherwise be required to sync.

                As such, if it wont work without ownership, then it's a little pointless.

                Maybe it's a bug in the current version but it actually doesn't sync at all, regardless. I made a new blueprint, added a cube, set the cube to simulate physics, set the blueprint to 'Replicates'. Just doesn't do it.

                Look at this video - the character is being corrected when hitting the box on either the client or server, because it's not synced.

                https://streamable.com/v39ye

                Comment


                  #23
                  Looking through your source now.

                  First, please stop using GetPlayerController 0, you'll see it in tutorials a lot and should rarely actually be used and many tutorials are made by people who hacked a solution and thought to share it, not experienced devs. Rule of thumb - if you can't get a reference properly, you're doing something wrong. It returns the first local player controller and that is rarely what you actually want - especially on the server.

                  In your case, you don't really need to find a better way to get the player controller because this plugin wont work with an owner for reasons already mentioned.

                  This piece of code here is nasty:

                  Code:
                      // TODO: Is Unreal really going to make me send my own information back out to myself?
                      // look up a better way.
                      // If I own the object, don't sync it.
                      if (realObjectToSync->GetOwner() == UGameplayStatics::GetPlayerController(GetWorld(), 0))
                      {
                          return;
                      }
                  If the owner is a player controller, you can just check if it's a local player controller, or even GetOwner()->GetNetConnection() != nullptr which pretty much works because of the entire problem you're facing - no one else can call RPCs on it.

                  For this plugin to work, clients must not send their data. You really should simply be replicating the information and not multicasting it, it's a waste of bandwidth. Replication is much more efficient.

                  It seems common to just have the server control the position in Unreal when there is no owner though so I might implement it in the next update.
                  That should do it
                  Last edited by Vaei; 08-03-2018, 06:27 PM.

                  Comment


                    #24
                    Vaei
                    Sorry, I'm new to Unreal so the terminology is a little different. When I said the server owns the object I meant it is owned by the Actor that is controlled by the person who is running the server on their computer. Thanks for the definition tips.

                    I believe your replication problem is because your object is set up incorrectly. Even Unreal's replication doesn't work with your set up. I think it's because you are trying to replicate something else's position and not the cube's. Drag the cube into the level first and then put a blueprint on that and it will replicate the cube's movement. Check out this post with relevant Unreal Stack Overflow explanation and a screenshot.

                    I do not understand how you can call RPCs from objects you don't own anyway. I don't think anyone can just call an RPC on any object that they want without ownership.

                    Client RPCs: "If the RPC is being called from client to be executed on the server, the client must own the Actor that the RPC is being called on."
                    And MultiCastRPCs: "If they are called from clients, they will only execute locally, and will not execute on the server."

                    Typically I would think you would send over an RPC to the server which would then send an RPC to PlayerControllerB (the owner in your scenario).

                    It will take some time to process and research a bit more about your second post so I'll reply to that later. Thanks for the tips!
                    Last edited by fuestrine; 08-03-2018, 06:51 PM.
                    Sync your transforms Smoothly across the network.

                    Comment


                      #25
                      Originally posted by fuestrine View Post
                      Vaei
                      Sorry, I'm new to Unreal so the terminology is a little different. When I said the server owns the object I meant it is owned by the Actor that is controlled by the person who is running the server on their computer. Thanks for the definition tips.
                      That would imply this only works on a listen server, not a dedicated server. With 2 players max.

                      Originally posted by fuestrine View Post
                      I believe your replication problem is because your object is set up incorrectly. Even Unreal's replication doesn't work with your set up. I think it's because you are trying to replicate something else's position and not the cube's. Drag the cube into the level first and then put a blueprint on that and it will replicate the cube's movement. Check out this post with relevant Unreal Stack Overflow explanation and a screenshot.
                      The object is setup as per the instructions in the provided documentation and does indeed work with unreal's replication system.

                      Originally posted by fuestrine View Post
                      I do not understand how you can call RPCs from objects you don't own anyway. I don't think anyone can just call an RPC on any object that they want without ownership.
                      That's why you don't use RPCs. An item in the world should not be owned. That goes against unreal's design.
                      Last edited by Vaei; 08-03-2018, 08:21 PM.

                      Comment


                        #26
                        Vaei
                        I made a new blueprint, added a cube, set the cube to simulate physics, set the blueprint to 'Replicates'. Just doesn't do it.
                        I'm not able to get it to replicate movement using Unreal's replicate movement this way.

                        If instead you Add a cube, Add a blueprint to the cube, Set the cube to simulate physics, Set the blueprint to "replicates" and "replicates movement", then Unreal's Replicate movement will work and so will Smooth Sync (with SetOwnerToServer checked, EDIT: and "replicates movement" unchecked).

                        If this is not the problem, can you give me some screenshots of your Actor you are trying to sync? Also any other relevant information to recreate this issue will help.
                        Last edited by fuestrine; 08-04-2018, 01:29 PM.
                        Sync your transforms Smoothly across the network.

                        Comment


                          #27
                          I believe the real motive behind this plugin is to have deterministic actor around the multiplayer computers.. am I right?

                          Comment


                            #28
                            Syed
                            You are correct, I think.

                            With Unreal's replicate movement, the server is forced to determine the position of all actors. The main motive for the plugin is so that users can set it up so that any client can control the position of an actor. With client control, the actor gets to move immediately on the owner's screen instead of using player prediction or waiting for the server to move the actor and for the information to get back to the client.

                            Let me know if you have more questions.
                            Sync your transforms Smoothly across the network.

                            Comment


                              #29
                              The 'stock' UE4 rigid body replication is not deterministic ie if you kick an object for an example several times, the server and client may not have the same position and rotation of the actor.

                              Comment


                                #30
                                Syed
                                Oh, that's interesting. Thanks for the info. Yes, Smooth Sync is deterministic in that sense. The position and rotation are determined by the owner and the actor is attempted to be in the same place on all connected game instances.

                                EDIT: I think Unreal's replicate movement is server deterministic from my testing(maybe only under certain circumstances). Smooth Sync can be both server deterministic and client deterministic on any actor that I've tested.
                                Last edited by fuestrine; 08-08-2018, 01:30 AM.
                                Sync your transforms Smoothly across the network.

                                Comment

                                Working...
                                X