Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Smooth Sync - Smoothly network rigidbodies and transforms while reducing bandwidth

Discussion in 'Assets and Asset Store' started by Fuestrine, Aug 4, 2017.

  1. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @ContinuumRL
    It sounds like you are trying to set the transform of an unowned object, which setting the transform of unowned objects is how SmoothSync works so it's going to conflict. Not much you can do there. You're going to have to not be syncing all the child parts if you want to use them to animate on the other side or switch it off and on or between things or something.
     
  2. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    42
    Will this asset resolve "corner snapping" issues? Currently, with the NetworkTransform Rigidbody, if I try to navigate around a boxcollider with a diagonal movement, the client will see the character snap instead of properly get nudged and run past the boxcollider. I can fix this by ramping up the network send rate but then I get jittery movement elsewhere. Thanks!
     
  3. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @dadamsj1
    It sounds like you are saying it goes through the corner of a box collider on the client? This sounds like probably because you only get messages every now and then. So if you get one message on one side of the corner and the next on the other side of the corner, it doesn't really know that you took a different path to get there instead of just a straight line.

    Smooth Sync would solve this by having the ability to send the Transform at any time you want but you'll have to tell it when. So like maybe you'd have a small collider on the corner that triggers it into forcing the Transform to send once regardless of how many times per second you set the syncing to be.

    Let me know if I misunderstood the issue or if you have more questions.
     
    Last edited: May 9, 2018
  4. Contiinuum

    Contiinuum

    Joined:
    Jun 24, 2017
    Posts:
    6
    Hey @Fuestrine,
    In my game I have minions which are being moved through a custom 2D controller. I wanted it so that only the server is moving those minions and then sync them with SmoothSync. However, whenever they jump, they're extremely jittery on clients. So I thought I'd let server and clients both move the minions and only correct the position of the minions if they're too far off of the server's position. Did that, still jittery. Now, which approach is smarter when using SmoothSync: server-handled or locally? And what settings in SmoothSync would be best suited for that?

    Thanks again.

    edit: minions don't have a Rigidbody, they move with transform.Translate()
     
  5. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    Any idea how to debug this? SmoothSync isn't working at all on my Player object. It is a pretty complex object with a Rigidbody2D and some children, but only the root needs to be synced. NetworkTransform was working, but when I replaced it with SmoothSync, there was no more syncing. I tried with several settings including default settings.

    I created a new object in the scene with a Rigidbody2D, NetworkIdentity (local authority), and CircleCollider2D, and SmoothSync works great on that. I tried disabling all components on the Player too so there's nothing that is settings its position or anything (although that shouldn't have anything do with it right?) and it still doesn't sync. I also tried spawning the object as a scene object instead of with NetworkServer.Spawn, still no syncing. I can't tell what's the difference between this object and others that do work...
     
  6. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @ContinuumRL
    Hmmm, them being jittery doesn't sound good. One simple trick is to change whereToUpdateTransform to Update instead of FixedUpdate(). I don't really recommend it for physics but it'll make it smoother. One other problem might be just that you aren't sending enough updates or are moving too fast. If you only send a two updates while jumping, it might make some weird movements that aren't the full shape of the jump.

    One other common problem I see is that people try to move the position of non-owned objects. This will definitely produce jitter as SmoothSync and yourself may be trying to update the position at the same time. You'll probably want only the owner to handle position updates.

    Either server or client owned can work with SmoothSync. It basically just depends on if you want full server authorization or not and how accurate you want your collisions to look for each machine.

    Let me know if none of this helps or if you have more questions.
     
    Last edited: May 10, 2018
  7. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @foolmoron
    It sounds like you might be trying to update the position of your player controller on non-owned objects. I'd start off by making sure none of your movement code from your player controller is happening on non-owners. It may be causing it to stay still every frame since no one is pressing a button. I don't see why NetworkTransform would work instead though, maybe they use LateUpdate()? I think that would just obfuscate the problem more than solve it though.

    Let me know if this doesn't solve your problem or if you have more questions.
     
    Last edited: May 10, 2018
  8. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    @Fuestrine
    Yeah that's why I tried disabling everything that would be setting the Player's position and it still didn't work.

    BUT I restarted my computer, and for some reason now the Player object does sync properly (with all my components and input systems and such enabled too), but ONLY the scene object. The NetworkServer.Spawn Player objects are not being synced despite being the exact same prefab. Could it be a netId or controllerId issue (I set custom ones for these player controllers)?
     
  9. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @foolmoron
    Ah, maybe, I use the Network Identity for many things and I set it in Awake(). Try setting the netID variable on Smooth Sync to your new Network Identity when you switch it out and let me know how it goes. I might be able to build something into it, but let me know if it solves your issue.
     
  10. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    I did some debugging and it looks to be based on
    hasAuthority
    which seems to be always false for my objects that are spawned by NetworkServer.Spawn, and so the state messages aren't being sent. This also explains why the scene object worked fine, because its local authority was working properly.

    I used NetworkServer.SpawnWithClientAuthority and it works now... not sure why NetworkTransform didn't seem to care about client authority.
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @foolmoron
    Ah, that makes sense. I think NetworkTransform takes the client owned positions and changes position on the server and then sends the server position out to clients regardless of authority, while I send from the client to everyone so they are all more or less equal. Glad it works now, feel free to hit me up with any other problems.
     
  12. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    I'm having the same issue on an authorative setup. Is there any way around this without giving clients authority?
    I'm prototyping a heavy physics based game where multiple clients can interact with physics objects at the same time.

    Hence the need to simulate characters and physics objects on the server and update their remote client proxies afterwards, for precision and anti cheat (competitive game modes are planned).

    NetworkTransform works as expected (works but unpolished and jittery), as you said, to get SmoothSync to work in this case, it would need to either allow the skipping of the client step and go straight to the 'send server position out to clients' or a way to ignore hasAuthority. Please let me know if it's possible, otherwise I'll have to get to work on a manual implementation of transform syncing.
     
  13. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Hummy91
    If you want to sync from the server to clients you just need to have the server be the owner. Uncheck "Local Player Authority" on the NetworkIdentity on your object you want to sync and the server will be the owner automatically when it's spawned with things like NetworkServer.Spawn().

    Let me know if I misunderstood the problem or if you have any issues.
     
    Last edited: May 11, 2018
  14. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    Sadly that is already the case.
    In my current project, I have a player character object which is spawned by the server via Network.Spawn (so these are all server owned).

    All clients send their input to the server which moves its owned copies of the player and then sends those translations to the clients.

    Sticking a UNET NetworkTransform on the player prefab syncs these updates, but replacing it with SmoothSync results with the player (on the server) moving and the client players all stationary.

    Probably worth mentioning, my Custom network manager spawns a player 'identity' which handles player spawning. Network.Spawn is called on the server to give the server ownership over playerCharacterObjects/Avatars.
     
  15. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Hummy91
    Well that's not good. Sorry about the issue.

    I just tested NetworkServer.Spawn() in the example scene and it's working for me with SmoothSync. Since NetworkTransform is working and SmoothSync isn't, I'd be happy to take a look at your project myself to try to find the issue. Try to strip it down before sending it to me if possible and tell me how to recreate the issue and where your spawn code is.

    If you don't want to send it to me, I've got some questions:
    What version of Unity are you using?
    What is the exact way you spawn? Paste me the relevant code.
    Can you screenshot me your object you are trying to spawn and the components on it?
    Are you saying you spawn the object and your client input commands go to the server and it moves on the server but the client can't see them move?
     
    Last edited: May 12, 2018
  16. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    The help is appreciated!
    I'm using Unity 2017.4.2f2 (I only upgraded a few days ago infact).

    "Are you saying you spawn the object and your client input commands go to the server and it moves on the server but the client can't see them move?" Yes that's exactly it, the object is spawned by the server on the server when the client connects.

    I did my best to comment the relevant parts (this is one of many iterations in my network prototyping so it's barebones and I may have missed a few methods), I moved all relevant scripts into the "Scripts/SmoothSyncRelevantScripts" folder and cleaned up the editor view. Most of the stuff happens in the PlayerIdentity script.

    In the editor window, I left the PlayerCharacterPrefab. So you can activate the prefab and toggle the NetworkTransform and SmoothSync to test each after applying the prefab changes.

    https://drive.google.com/open?id=1riZPirC5qEHwOzHdakMfiWgUS7iwzUuK

    Edit: It looks like I've fixed it, and it was something on my end that I need to look into apologies. Some script or other was throwing an error which wasnt showing on my client (new install of unity doesnt seem to build in debug mode by default?) which was breaking everything apparantly.
    Thanks for your time! Sorry again.
     
    Last edited: May 12, 2018
  17. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Hummy91
    No problem. Happy to hear it's fixed. Let me know if you have anymore issues. If you like my asset and support, every 5 star rating helps us get noticed more. :) Cheers.
     
  18. Trainwiz

    Trainwiz

    Joined:
    Aug 25, 2015
    Posts:
    20
    What would be the ideal settings on objects that move extremely fast? I'm working on the multiplayer for a spacefighter game, and my ships can move anywhere from 100 units to 400 units a second and obviously things get kind of jittery, as so demonstrated.



    Great asset otherwise, been using it for other objects and short of a few edge cases (and obviously this whole part) it's perfect.
     
  19. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Trainwiz
    Oh golly that's a lot of units, sorry about the issue. I definitely never fully tested at such high speeds.

    Try these:
    Turn off all compression.
    Change WhereToUpdate to Update.
    Make sure your PositionSnapThreshold is really high to compensate for your fast movement.
    Set your send and receive thresholds really low or at 0.
    Increase your ExtrapolationDistanceLimit to really high to compensate for your fast movement.
    Set interpolationBackTime to .5

    You won't want to keep all of these settings, but if you change all of these and you still get jitteryness then I'll definitely have to make a more core fix for that kind of speed.

    If it does fix your problem, try to see if you can isolate which change fixes your problem and I can probably give you more tips or I can change how things are done in the background to make more sense for high speeds.
     
  20. Trainwiz

    Trainwiz

    Joined:
    Aug 25, 2015
    Posts:
    20
    Hm, trying out even all of these there's still quite a lot of jitter, even when the ships are going comparatively slow. It's alright that the issue exists though, I understand that such high speeds are kind of a rare situation in the first place.
     
  21. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Trainwiz
    I know there become small differences when you get to really large numbers and Unity may start breaking at even smaller distances from the origin, but I would think you'd see similar problems in single player if that were the case.

    If it's not difficult, try running your ship closer to the origin (0,0,0) if you are far from it and see if it still shakes?
    If it still shakes then I definitely will want to fix it, I can't just be having my product not work for any sane reason. I'll be able to get some time to make a scene and try out some high speed stuff in the next couple days or so either way.
     
    Last edited: May 17, 2018
  22. Sempiternal

    Sempiternal

    Joined:
    Jun 18, 2014
    Posts:
    114
    Just bought this a few hours ago and still can't get it to work. For some reason the example scene works but my scene does not. I did exactly what the reviews said, delete the network transform and replace with smoothsync.cs, but this is not working. The player object just stands still on the client side and will not update. I also noticed that in the example scene, there was still a small delay in the real-time updates (about 0.2 seconds). I tested the server in the editor and the client on my Note 8 Android phone.

    With network transform the delay is about 0.2 seconds for the client update so I never really had a problem in the first place but I just wanted the movement to be as real-time as possible as this is essentially a multiplayer hockey shootout type game. If the delay is similar with this plugin not sure what I benefit from it, but I am sure I can get it faster if I actually mess with the settings. If you can help me out that would be great!

    **Edit: It seems to work on player 2's object, which is the client. I set it up so that the host starts out as the attacking puck, and the defender starts out as the goalie. Goalie movements sync, however the hosts movement does not sync with client.

    I tweaked the settings as best I could to try and get the real-time as close as I can but I am finding slightly better results having a network transform with rigidbody 3D sync.

    At this point I fear in order to get this plugin working correctly, I will have to rework areas in my project such as client authority, network spawning, etc since apparently only the client updates to the host. This isn't something I wanted to do as the biggest reason behind me purchasing this asset was the "drop it and it works instantly" aspect. It also isn't worth going through all that if the network transform is giving me slightly better results.

    I feel like this plugin will benefit me in more complex projects involving more updates and units but for now I think with my small project I'll just stick with what worked before.
     
    Last edited: May 17, 2018
  23. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Sempiternal

    There is a small delay because InterpolationBackTime forces a small delay so you are always at a known position even with a hiccup in the network. This is how games like Counter-Strike do their networking. You can lower InterpolationBackTime to get a more responsive time but the trade off is that you will extrapolate (go into the unknown) more often when lag spikes happen.

    It sounds like you don't have ownership working correctly. If you continue on this path you are going to have more networking problems like not being able to send RPCs / CMDs on these objects since the ownership (hasAuthority) isn't what you think it is. It also seems you'll have problems when using Network Transform and moving this same object from a client(non-server), spawning the way you currently do.

    Network Transform allows you to not have correct ownership of objects since it just sends server positions out regardless of ownership. It seems like you are moving an object on the server that isn't owned by anyone. Smooth Sync only sends from owners to non-owners (because how else would you determine who controls the position?)

    To make the server determine position, make the server the owner. Uncheck "Local Client Authority" and when you spawn with things like NetworkServer.Spawn(), the server will automatically be the owner.
    To make the client determine position, make the client the owner (the server is also a client). Spawn with things like SpawnWithClientAuthority(). You can pass in NetworkServer.connections[0] to make the server the owner since the 0 connection is always the computer you are on.

    Let me know if I rambled too much or if you have any questions.

    You can also ignore all of that technical jargon and just screen shot me your spawn code and your Smooth Sync settings and I can provide a simple solution to get your ownership correct most likely. No one should be forced to use Network Transform if I can help it. :)
     
    Last edited: May 17, 2018
  24. Trainwiz

    Trainwiz

    Joined:
    Aug 25, 2015
    Posts:
    20
    Checking it out, distance doesn't seem to matter. Even right next to the origin there's still a lot of jitter.
     
  25. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Trainwiz
    OK, I'll take a look into speeds between 100 units a second and 400 units a second and see what I can figure out.
     
    Last edited: May 17, 2018
  26. KNKRNAVEEN

    KNKRNAVEEN

    Joined:
    Jul 3, 2017
    Posts:
    2
    few days back I bought this asset,i cant understand that how It is to use and I am beginner to this unity .I want to move the sprite smoothly in four axis and I wrote code using input.get axis and rb.velocity to move the sprite in four directions by using arrow keys but it dosent move smoothly,then I bought this asset and I attached the smooth sync script to sprite as u said but when I runs the game the sprite was disabled even at the same time I enabled that sprite after also it doesn't move smoothly.can u give me clear explanation to move the sprite smoothly as soon as possible..
    .
     
  27. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @KNKRNAVEEN
    Are you talking about a networked game? This asset is for smooth syncing across a network. I'd be happy to issue a refund if you bought the asset by mistake.

    If you are talking about a network game, does it not move on both the client and the server no matter who the owner is? What is your code that you use to spawn the object on the network?
     
  28. KNKRNAVEEN

    KNKRNAVEEN

    Joined:
    Jul 3, 2017
    Posts:
    2
    No sir,my game is not networked game,just like a 2d platformer moving sprite in four directions in smooth.I was completely misunderstood this asset.I think it was not useful to me.can u please refund my amount.
     
  29. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @KNKRNAVEEN
    Yeah, Smooth Sync is only for networked games. Privately message me your invoice number and I'll put it through.
     
  30. Sempiternal

    Sempiternal

    Joined:
    Jun 18, 2014
    Posts:
    114
    Thank you Fuestrine for the swift and prompt response!

    As I am new to UNET I probably do have the ownership setup incorrectly but after going through dozens of videos and tutorials I am just glad I have it working as is. The way I have it setup is in my NetworkManager script whenever a player joins it spawns a camera which has a script called PlayerSetup on it. This script has the following lines of code:

    Code (CSharp):
    1.         IEnumerator checkr () {
    2.  
    3.                 yield return new WaitForSeconds(1f);
    4.  
    5.                 if (isLocalPlayer && isServer) {
    6.                    
    7.                         //Debug.Log ("thisisServer");
    8.                         ThisIsServer = true;
    9.                         this.transform.rotation  = Quaternion.Euler(90, 0, 0);
    10.                         RpcpuckSetup();
    11.                         //Debug.Log("endServer");
    12.  
    13.  
    14.  
    15.                         //searcher();
    16.  
    17.                 }
    18.  
    19.                 if (isLocalPlayer && !isServer) {
    20.                         //Debug.Log ("thisisClient");
    21.                         ThisIsServer = false;
    22.                         this.transform.rotation = Quaternion.Euler(90, 0, 180);
    23.                         CmdgoalieSetup ();
    24.  
    25.                 }
    26.  
    27.         }
    The reason I have it delayed by 1 second inside of an IEnumerator is that I discovered UNET will not tell who the host and client is immediately after launch, but rather a short delay after, hence the 1 second.

    This script calls an RCP function from the server and a COMMAND function from the client.
    Code (CSharp):
    1.         [ClientRpc] //server issuing to all clients
    2.         void RpcpuckSetup (){
    3.  
    4.                 this.gameObject.name = "player1Cam"; //change this gameobjects name to "player1Cam"
    5.  
    6.         }
    Code (CSharp):
    1.         [Command] //client asking server
    2.  
    3.         void CmdgoalieSetup (){
    4.  
    5.                 GameObject puck = Instantiate (playerPuck, new Vector3(-12,0,0), Quaternion.identity);
    6.  
    7.                 NetworkServer.Spawn (puck);
    8.  
    9.                 GameObject puck2 = Instantiate (playerPuck2, new Vector3(-12,0,0), Quaternion.identity);
    10.  
    11.                 NetworkServer.Spawn (puck2);
    12.  
    13.  
    14.  
    15.                 GameObject goalie = Instantiate (goaliePuck, new Vector3(12,0,0), Quaternion.identity);
    16.  
    17.                 NetworkServer.SpawnWithClientAuthority (goalie, connectionToClient);
    18.  
    19.                 GameObject goalie2 = Instantiate (goaliePuck2, new Vector3(12,0,0), Quaternion.identity);
    20.                 NetworkServer.SpawnWithClientAuthority (goalie2, connectionToClient);
    21.  
    22.  
    23.                 GameObject gs = Instantiate (GSM, new Vector3(0,4.54f,-1.29f), Quaternion.identity);
    24.  
    25.                 NetworkServer.Spawn (gs);
    26.  
    27.                 RpccameraSetup ();
    28.  
    29.         }
    The reason I allow the client to spawn the gameobjects is because I don't want the objects spawned until both players are ready. Since the host is hosting, he is ready, but is waiting for a client to join to actually begin the match.

    Based on this, it looks like I am giving authority properly, but of course like I said I am completely new to this and am probably wrong.

    Again, I never had a problem calling COMMANDs from the client or RPCs from the server. NetworkTransform worked fine for me but smoothsync is only working on clients, as in movement from the clients updates to both players whereas movement from the server does not.

    I also want to note that I do indeed have the local player authority box checked on all player objects. I was really confused on this topic, but I thought that if the server only box is checked then only the server can see the object and the clients can't, which is why I have the local player authority box checked.

    Two other questions:

    1. What is the network channel and why is it set to 1 by default?

    2. Is putting the send rate over 30 better if I want this synced as smoothly as it can be?

    Thanks!
     
    Last edited: May 18, 2018
  31. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Sempiternal
    Yeah, it's because you have local player authority checked and no one is actually an owner of that object when you spawn with NetworkServer.Spawn(). I'm not sure why they even allow you to spawn an object on the network without an owner but there's probably some severe edge case where someone would want this. NetworkTransform works despite an owner not being set, because NetworkTransform is poorly made.

    It sounds like you want to do this:
    Spawn your pucks with:
    NetworkServer.SpawnWithClientAuthority (puck, NetworkServer.Connections[0]);
    and
    NetworkServer.SpawnWithClientAuthority (puck2, NetworkServer.Connections[1]);
    Spawn your goalies with:
    NetworkServer.SpawnWithClientAuthority (goalie, NetworkServer.Connections[0]);
    and
    NetworkServer.SpawnWithClientAuthority (goalie2, NetworkServer.Connections[1]);

    This will make "puck" and "goalie" controllable by the server and "puck2" and "goalie2" controllable by the first connected client. I'm not sure who you want the owner to be of "gs" but do the same to that object depending on who you want to control it.

    If you want more players, you can loop through the current connections and spawn, but we'll leave that complication for later.

    Question 1:
    Network channels are ways Unity sends out information. Basically, it can be reliable or unrealiable. Reliable is guaranteed to arrive but it'll also bog down the network if you have too many. Unreliable may not arrive and is used for things like position updating (Smooth Sync) where if you send 15 positions a second and only 14 get there, it's not a big deal.

    Question 2:
    30 should be more than enough. You should be able to lower it but it all depends on how accurate you want it to be. It shouldn't really affect actual smoothness of the object.

    Let me know if you have any difficulties or questions.
     
    Last edited: May 18, 2018
  32. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Trainwiz
    Hi, sorry about the issue. I have made it so that it doesn't twitch like crazy at super high speeds anymore! I had to make a fairly core change to Smooth Sync so I'm going to have to do some extensive testing at some point in the next week before I put it on the store though.

    If you want it now, let me know what version of Unity you are using and I'll send you a copy for that version.

    You still get some super minor twitches but it's way better than it was before. I think it's just a physical limitation at such high speeds while your camera tries to match the speed of that object too. Going 400 units a second and then I have to lerp to the latest received position, it's just not going to be as perfectly smooth as going in a straight line at 400 units a second locally. I tested the other Network Transform syncing assets on the market and they look much worse.
     
  33. Sempiternal

    Sempiternal

    Joined:
    Jun 18, 2014
    Posts:
    114
    Thank you for this. The local player authority concept is honestly what kept me stuck for hours. No one ever mentioned giving client authority to server and client via code, they all kept using this local player authority crap which really confused the hell out of me. The way these videos described it was that Spawn by default goes to server and SpawnWithClientAuthority is for clients.

    Nevertheless, after using the code you provided and modifying some of the smoothsync values (I set interpolation to 0.015, left extrapolation to 0.3, set all syncs to none except position, and upped data send from 30 to 70) the gameobjects are moving VERY smoothly now. I left the local authority box checked because checking the server box instead or leaving both boxes blank does not spawn objects on client. I did do an expirement where the interpolition and extrapolition were set to zero and received similar results. Is leaving them both at zero recommended for maximum real-time sync?

    gs is the GameStateManager, which handles what round it is, who is attacking/defending, scoreboard, victory/defeat conditions, etc. It doesn't really matter who owns this as it isn't an interactable object, but I just spawn it with server authority anyway.

    Also thanks for the network channel and send rate information. I will go ahead and leave the network channel at 1.

    I will keep you in the loop just in case I encounter any oddities, but so far everything is looking great and the smoothness adds a fresher feel to the game. Great work and thank you for the help!
     
  34. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Sempiternal
    No problem at all. Happy to hear it's working as intended.

    Putting InterpolationBackTime at 0 will indeed make it more real time. But this is a tradeoff where if you don't receive any messages for your InterpolationBackTime, you will start extrapolating into the unknown.
    Putting ExtrapolationDistanceLimit at 0 will make the object immediately stop when it starts extrapolating. Extrapolation only happens when you don't receive messages for the time of InterpolationBackTime. This is so the game can keep going during networking hiccups without hopefully being too far off of where the object is supposed to be.

    Let me know if you have anymore questions. Cheers!
     
  35. Sempiternal

    Sempiternal

    Joined:
    Jun 18, 2014
    Posts:
    114
    Thanks. I tested InterpolationBackTime and ExtrapolationDistanceLimit at 0 and seemed to get similar results. Do you recommend that if one of them is zero the other one should have a value greater than 0?
     
  36. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Sempiternal
    No. I recommend never setting ExtrapolationDistanceLimit to 0. Put it at about 5 times your object diameter and you should be fine for most cases. Better to have it too large than too small.

    I recommend InterpolationBackTime to be around .1. Feel free to lower it for quicker reactions on non-owners but it will look worse during lag spikes.
     
  37. Trainwiz

    Trainwiz

    Joined:
    Aug 25, 2015
    Posts:
    20

    Well I'm on 2018.1.0f2, but I'd rather wait until it's out on the store. Thank you so much though, this was one of the last remaining issues for my game's multiplayer.
     
  38. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    @Fuestrine
    So I am testing the sync with the NetworkManager simulated lag (100ms and 1% packet loss), and it's really choppy. It's a rigibody2D bouncing between two walls at less than 10 units/sec, so I feel like it should be really smooth. There's nothing unexpected happening or anything.

    Is there something obviously wrong in my settings to fix this? There's so many options I probably messed something up.
    https://i.imgur.com/HhgPF3a.png

    Here's a vid of it (horrible imgur quality)
    https://i.imgur.com/3Q2kSug.gifv

    I tried disabling velocity syncing as well, leaving only position syncing, since my game already syncs and sets velocity and such, and it looks pretty much the same. I also tried syncing a new object that is just the RB and the same smooth sync options, no code touches it at all, and it's also choppy.
     
  39. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    Hey Fuestrine, I wanted to drop a question regarding SmoothSync. As I'm fairly new to networking as a whole I may have no idea what Im talking about, so bear with me :p.

    I'm working on a very physics heavy game, and so far, to get the results I need, I've been using smooth sync and a combination of my own CMD/RPC syncing.
    This is so that physics based characters can interact with physics based objects smoothly but also timely, so there are no awkward sync gaps between say a hand and an object.

    Now it was my understanding that in order to pull this off I couldn't comfortably implement techniques such as interpolation/extrapolation. But I am considering it, given the growing nature of my project.

    With that in mind, am I correct in understanding, that for my specific usecase, I would have to set for example, SmoothSyncs interpolation settings to the same values for all SmoothSync components in my project? In order to get everything such as collisions and interactions to 'sync' up via interpolation?

    As my understanding of interpolation leads me to think that for example; 'interactable box A' with SmoothSync and 'player hand' with smoothSync would not be sync'd near perfectly if using interpolation with different interpolation settings?

    Also, for physics simulations and syncing, whats the 'safest' highest send rate you'd recommend when dealing with fairly fast moving rigidbodies or transforms?

    Thanks for your time,

    ~ Hummy
     
    Last edited: May 25, 2018
  40. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @foolmoron
    My first guess is that it's dropping in and out of extrapolation a bunch of times a frame since your InterpolationBackTime is exactly equal to your ping. You'll want your InterpolationBackTime to be larger than your typical ping. Try setting InterpolationBackTime to .2 and see if that fixes it. InterpolationBackTime sets everything in the past so that regardless of your ping up to that limit, it should be in about the same place on all systems at the same time.

    I'll get some time to take a further look at it this weekend to see if my extrapolation code needs some cleaning up but let me know if that fixes your problem.

    I'll also see if I can maybe group some of the variables up or something to make it a bit less confusing. What started out a lot simpler has grown with many feature requests.
     
    Last edited: May 26, 2018
  41. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Hummy91
    No problem at all. Networking is confusing even to the people who do it all the time. :)

    Yes, you'll want your interpolationBackTime to be the same on all objects if you want them to interact the best that they can.

    The higher the send rate the better I would imagine. 30 is usually more than enough though.

    I'm not really sure what road you are going down but keep in mind that doing literal physics collisions with separate owners is just never going to be that great. (like billiard balls bouncing off each other). You'll probably have to network some AddForce() to make it look decent.
    If you are just doing trigger collisions like bullets hitting a player and such, you'll be fine.

    Explaining the billiard balls situation with separate owners:
    Basically, in a perfect system, you'll never get the positions to actually collide since with perfect tracking, the objects would only go to the collision point and then reflect off the collision point. So they never actually collide when it gets sent over the network since they aren't going into positions they have never been.
    With same owners:
    If you want perfect collisions you'll have to make all of the objects owned by one system(server) so that they can collide like normal and then send the position information out.

    I sort of rambled a bit so let me know if you have any questions.
     
  42. stevesan

    stevesan

    Joined:
    Aug 14, 2011
    Posts:
    65
    Hi all,
    Does SmoothSync support smooth ownership transfer? Ie. if I throw a ball to another player, and want to transfer ownership mid-flight, 1) can I do that with this component, and 2) how will it look for both players?
     
  43. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @stevesan
    1) Yes, smooth sync handles ownership transfer.
    2) Last I checked it was better than any Unity Asset Store competitors, but it will definitely not be completely smooth for ownership transfer mid flight. If you buy it and then find out another Network Transform replacement solution gives less of a hiccup on ownership transfer, I'd be happy to issue a refund.
     
    Last edited: May 27, 2018
  44. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    Hi.
    Does your solution support multiple child sync?
    I have a VR avatar with full-body tracking. I want to sync 6 devices which are children of the root player Identity. I used 6 Network Transform Child components before.
     
  45. Contiinuum

    Contiinuum

    Joined:
    Jun 24, 2017
    Posts:
    6
    Hey @Fuestrine,
    I have yet another question / issue. We just tested player movement over 2 different networks (so far testing has only been done in a local network, which works perfectly) and the players, who use Smooth Sync, are extremely choppy. It seems like they only recieve an update for their new position roughly every second. Theres no real smoothing going on, they just take big leaps. The players are moved through transfrom.Translate. The SmoothSync script has default settings on it. Do you know what might be the issue? Or if there's a specific setting i should change to make it better?

    Thanks.
     
  46. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @ContinuumRL
    That certainly doesn't sound right. Screenshot me your SmoothSync settings?

    One common thing is to make sure you aren't updating position on non-owned objects (for example: The server owns player 1, the client owns player 2. So the client shouldn't be moving player 1). Another thing might be to try with NetworkTransform and if the same issue persists, then it's probably something unrelated to SmoothSync.
     
  47. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @hottabych
    Yes, it works with multiple children.

    The example scene has the player object with a child so you can see it there, but I'll give a quick rundown. It is set up the same way NetworkTransform is so as to be very easily replaceable. you'll just add a SmoothSync script for each child you want to sync like you would with NetworkTransformChild and leave one blank as the parent (the NetworkTransform part).

    Let me know if you have anymore questions.
     
  48. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    @Fuestrine if i get you right, your script acts like a NetworkTransform if "Child Object" field is empty, and acts like a NetworkTransformChild if "Child Object" is filled?
    Also, I have a question about ownership transfer. Smooth Sync works on clients only. So, if NPC object is not owned by any client, it won't sync at all? Say, if I fire "Player.CmdRemoveAuthority(ball)", sync will stop?
     
    Last edited: May 30, 2018
  49. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @hottabych
    Yes, that is exactly how it works.
     
  50. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @hottabych Didn't see your edit until just now.
    Smooth Sync works on servers and clients and you can transfer ownership in game between them.

    Let me know if there's something confusing in my marketing materials that suggests that it only works on clients. It gets difficult to see the full picture through fresh eyes after awhile.