Search Unity

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

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

  1. Rickstrife

    Rickstrife

    Joined:
    Oct 25, 2013
    Posts:
    2
    Hello @Fuestrine

    I am trying to get my player to sync across the network using only the velocity only with 2drigidbody. But it is not working am not sure what I am doing wrong. Any advise would be tremendous. Below is an example of my project.
    (note: am able to get it to work with transform)
    (note: I was able to add PhotonRigidbody2DView on character and as an observed Componet. But I thought this was wrong I felt PUN2 should be able to do this without having to add that componet.)

    Project Context
    - Creating 3 pre-configured Character's on master across network
    - Having all characters do some action (jump)
    - Each Character has a different type of network syncing for us to compare each syncing type. (our old net code sync transform, pun2 transform sync, pun2 velocity sync )


    Test Scene

    upload_2020-4-22_16-11-6.png

    Componets on Character GameObject
    upload_2020-4-22_16-13-0.png
    upload_2020-4-22_16-13-37.png
     
    Last edited: Apr 23, 2020
  2. Gaucho

    Gaucho

    Joined:
    Apr 21, 2013
    Posts:
    12
    Hi there, great product so far! I just encountered a special situation for me:

    I've got a vehicle, in which players can step (they'll become a child of the vehicle, so that they can move inside the vehicle with local movement), and once they step out of it, they become a child of another gameobject (let's say "World").

    How to achieve that with smoothsync? Both possible parents (vehicle and world) do have the smoothsync-script attached to it. Do i have to add a component, once the player is attached to a new parent or will smoothsync handle that for me, as long as the player has a smoothsync component attached?

    I've stripped down my parenting manager to the bare minimum, maybe you can tell me, how to set that up correctly:

    Code (CSharp):
    1. public class PlayerParentingManager : NetworkBehaviour
    2. {
    3.     private bool _isInVehicle;
    4.     private Transform _playersOutOfVehicleParent;
    5.     private Transform _playersInVehicleParent;
    6.  
    7.     void Start()
    8.     {
    9.         _playersOutOfVehicleParent = GameObject.Find("World").transform.Find("PlayersOutside").transform;
    10.         _playersInVehicleParent= GameObject.Find("Vehicle").transform.Find("PlayersInside").transform;
    11.     }
    12.  
    13.     void Update()
    14.     {
    15.         if (isLocalPlayer)
    16.         {
    17.             var collisions = Physics.OverlapSphere(transform.position, 0.5f, LayerMask.GetMask("VehicleCollider"));
    18.  
    19.             if (!collisions.Any() && (_isInVehicle || transform.parent == null))
    20.             {
    21.                 _isInVehicle = false;
    22.                 this.transform.SetParent(_playersOutOfVehicleParent );
    23.             }
    24.  
    25.             if (collisions.Any() && (!_isInVehicle || transform.parent == null))
    26.             {
    27.                 _isInVehicle = true;
    28.                 this.transform.SetParent(_playersInVehicleParent);
    29.             }
    30.         }
    31.     }
    32. }
    So - do players even have to have a smoothSync-Script attached, or only the PlayersOutside and PlayersInside gameobjects with a second one ChildObjectToSync set to the player?

    Specifically asking - do i have to do the parenting on my own on every client by sending a message to them that the parent changed, or will smoothsync take care of that?

    Another question:

    If i have a nested set of Gameobjects, of which i want to sync layer A and C:

    upload_2020-4-23_13-35-22.png

    How to set smoothsync up correctly?
    Adding SmoothSync-Component to A twice (one with none as ChildObjectToSync and another one pointing to B) and then adding one SmoothSync Component to B with ChildObjectToSync set to C?
    or adding three of them to Component A (one with none as ChildObjectToSync, one pointing to B and one pointing to C)?
    Or only adding two to A (one with none as ChildObjectToSync and another one pointing to C directly)?

    Thanks for your reply in advance - looking forward!
     
    Last edited: Apr 23, 2020
  3. phil-harvey

    phil-harvey

    Joined:
    Aug 27, 2014
    Posts:
    75
    Is there going to be a fix for the latest version of Mirror?

    I'm seeing ~35 errors due to changes to NetworkWriter for Mirror.
     
  4. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Gaucho
    Hey, I already replied to you in email but wanted to reply here too so people don't think I'm ignoring you. :)

    You will have to change the parent on every networked instance of that object. Smooth Sync should handle it from there. Worst case scenario is you may have to call SmoothSync.Awake on each SmoothSync on the object you are changing the parents/children of.

    For the A, B, C:
    Check out the provided Smooth Sync Mirror Example scene for a similar scenario.
    But if you want to sync just A and C. Put two Smooth Syncs on A and hook one of them up to C using the ChildObjectToSync public variable.
     
  5. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @phil-harvey
    It works for me with the latest version of Mirror on the Asset Store.
    Unfortunately I can't support each minor change they release on the Mirror github. Let me know if the Asset Store version doesn't work though, those are the major releases that I try to stay compatible with. Thanks for letting me know that a newer version will break it though, I'll also try to keep an eye out for it.
     
    Last edited: Apr 26, 2020
  6. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Baavoz
    What networking system are you using?
    When do the errors appear?
     
  7. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Rickstrife
    I don't think I've ever had someone try to sync only velocity before.
    Smooth Sync currently doesn't have this functionality.

    If you sync using only velocity, it will be very inaccurate and would only be useful in specific scenarios.
    One reason is that velocity is going to be different between send rates so it's going to not be able to stay at about the same position that well and it will only get more and more off as the game goes on.
    Also, if you get bumped or stopped by something (or stop getting sent velocities because of network lag) it'll just use the newest velocity sent even if it's been a few seconds of that player moving. So having your speed be 50, but being 1 second in the past, the positions are going to be pretty far off.

    Basically, I'd think about syncing position. Let me know if I misunderstood the issue or if you have any other questions.
     
  8. Rickstrife

    Rickstrife

    Joined:
    Oct 25, 2013
    Posts:
    2
    ah okay thank you very much. Appreciate the quick & detailed response.
     
  9. Gaucho

    Gaucho

    Joined:
    Apr 21, 2013
    Posts:
    12
    @Fuestrine Thanks for your reply, and aswell thanks for your emails. Good idea to keep writing here to solve issue aswell for others (if they do face it).

    Unfortunatelly, i still dont get the idea what exactly to do. Just changing the parent does not work, tried it aswell by extending the demo scene.

    Steps to reproduce:

    • Add a 3D called "MovingPlatform" , scale it to 40 / 1 / 40 and move a bit down (so that you can see the parent being moved) and add the attached PlatformMover.cs script to it.
    • Add an empty gameobject called "IdlePlatform".
    • Add to both a NetworkIdentity and a SmoothSync script (leave ChildObjectToSync) empty.
    • Add the ParentingManager.cs script to the player prefab SmoothSyncMirrorPlayerPrefab.prefab
    • Press M to parent to moving platform, press I to parent to idle platform.
    • Once a client hops in, the scales go crazy, so do the positions:
    upload_2020-4-28_21-27-41.png

    upload_2020-4-28_21-33-35.png

    According to the documentation, just changing the parent is wrong, as i'd assume to only have the smooth sync script attached to the top most root element, changing itself and the children.
    I've tried it aswell to add / remove the smooth sync script on every parent change on every client, but this fails asell positioning the objects accordingly. Script to add / remove the smooth sync scripts:

    Code (CSharp):
    1.  
    2. if (transform.parent != null)
    3.         {
    4.             // iterate through all current smooth sync scripts, and remove us from the objects to be synced.
    5.             var currentSyncComponents = transform.parent.GetComponents<SmoothSyncMirror>();
    6.             foreach (var smoothSyncMirror in currentSyncComponents)
    7.             {
    8.                 if (this.gameObject == smoothSyncMirror.childObjectToSync)
    9.                 {
    10.                     Destroy(smoothSyncMirror);
    11.                     break;
    12.                 }
    13.             }
    14.         }
    15.  
    16.         this.transform.SetParent(newParent.transform);
    17.  
    18.         var smoothSync = newParent.AddComponent<SmoothSyncMirror>();
    19.         smoothSync.childObjectToSync = this.gameObject;
    20.         smoothSync.enabled = true;
    21.  
    22.         smoothSync.Awake();
    23.         newParent.GetComponents<SmoothSyncMirror>().First(x => x.childObjectToSync == null).Awake();
    24.  
    What am i missing of the concept of smooth sync here?
     

    Attached Files:

  10. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Gaucho
    I'm getting some Mirror error with ParentingManager.cs. I'm not too experienced with Mirror these days so I'm not sure if some setup needs to be done.

    How about instead, can you upload the project with that example scene you described to dropbox or something and send me the link to it in an email?
    Then I'll get a perfect view as to what's happening.
     
    Last edited: Apr 30, 2020
  11. Gaucho

    Gaucho

    Joined:
    Apr 21, 2013
    Posts:
    12
    Thanks for your reply, i've mailed you an example with two different approaches. I was able to get rid of the weird stretching shown in the images, just for all others that are reading this here aswell. It wasn't a bug in smooth sync, rather than a behaviour of unity when reparenting to objects with a scale other than Vector3.one.
     
  12. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
    Is it normal when using Pun2 for your first movement to be jittery? After moving then things are smooth but the very first movement input are jerky. As though smooth sync engines are starting up. Any help?
     
  13. Erdal42

    Erdal42

    Joined:
    Sep 17, 2018
    Posts:
    19
    Just joined the Discord...

    THIS PROJECT IS DEAD.
    DO NOT BUY ...
     
  14. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
  15. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396
    What a name you have! :)

    Yes, it is normal. In the first second of movement, it is getting used to your relative ping so that it can be as good as possible as soon as possible.
    I tried making it shorter but people were reporting issues. You can change line 2041 in SmoothSyncPun2.cs
    if (receivedStatesCounter < PhotonNetwork.SerializationRate ||
    to
    if (receivedStatesCounter < PhotonNetwork.SerializationRate / 2.0f ||
    or divide by a larger number to make this time period even smaller if you want to try it out.
    In the future, I want to make it so this happens regardless of moving and it just sends for one second when the game is joined so that it is less noticeable but I haven't had time for it yet.

    Let me know if you have any questions.
     
    Last edited: May 14, 2020
    CoyoteFringe likes this.
  16. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Erdal42
    We are up to date on all replies here and it's only been two days since the latest post needing a reply here. This project isn't dead. :p I am sorry that we haven't been on discord in some weeks though so I understand how you feel. If it happens again, please feel free to poke us again by email or forums.
     
    13E12K and CoyoteFringe like this.
  17. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    It's been a few months now and I haven't seen a new release.
    Any idea when this functionality will be released?
     
  18. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @katasteel
    Sorry about that, I was trying to release another fix at the same time and then the whole release fell to the side. I'll move this to a high priority and get it out quickly.
     
  19. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    That would be great.
    Thanks a lot.
     
  20. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @katasteel
    Just submitted it to the Asset Store so I'd expect it in a few days. I'll let you know when it's out.
     
  21. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    where is the change logs ?
     
  22. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    Version 3.26 is now on the Asset Store.

    Change log:
    • Updated to work with latest Mirror release.
    • Performance improvements for Mirror.
    • Added server authority support via Transform Source option.
     
  23. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
  24. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @katasteel @phil-harvey
    Smooth Sync Mirror that works with latest version of Mirror on the Asset Store is now out. Sorry about the wait.
     
  25. jasonofthestorm

    jasonofthestorm

    Joined:
    Aug 22, 2017
    Posts:
    4
    Hi, is there any chance this asset works (or could be easily converted to work) with Normcore? I recently switched from Photon and would like to make sure before purchasing. https://normcore.io/
     
  26. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @jasonofthestorm
    Smooth Sync would not automatically work out of the box with anything other than the supported networking systems.

    I don't know anything about Normcore but if it can send a byte array across the network and you are an experienced coder, I would think the Photon version of Smooth Sync wouldn't be too crazy to convert to Normcore. But I can't really recommend it as I don't know how difficult it would be. Knowing Photon networking basics would help. Smooth Sync wasn't really made with universality in mind, it was made to be plug and play with the most popular networking systems.
     
  27. keybol23

    keybol23

    Joined:
    Aug 13, 2013
    Posts:
    26
    Can you give a recommended setting for a game like this.
    Game is top down, and players can move in any direction and also jump. Variables to sync is x,y,z of position and y of rotation. What would be your recommended Interpolation Back Time, etc and Extrapolation, Thresholds if any. Here's mine currently but I can see other moving players look like they're teleporting/glitching to where they should be running.
     
  28. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    181
    This is a great asset but apart from just trying every single combination of values I really wish there was some more guidance of settings. I am working at a serialisation rate of 5x /s (is that going to be too low for a fairly slow moving boat?) and i'm getting some hiccups. I believe I should set the interpolation back time as longer than than this so > than 0.2s ? Also - another specific question - how should the rigidbody interpolation be set up?
     
  29. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @keybol23
    Probably too broad of a question. It all depends on what you are trying to achieve. I'd just start with the default settings. If it's not teleporting/glitching with the default settings, then slowly change the others.
    One big thing to keep in mind is keeping InterpolationBackTime > 1/SendRate (serialization rate in photon land?) or you'll be extrapolating all the time which will cause weirdness.
    Extrapolation and thresholds should probably just remain at default as they won't affect much.
     
  30. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Redrag
    InterpolationBackTime should be kept greater than 1/SendRate (pretty sure this is called serialization rate in photon land?). So I'd try increasing it to .3 just to test if that's causing the hiccups or not.
    I don't think 5 sends a second would be too low, it all depends though on what kind of accuracy you are looking for though.

    I've attempted a guide in the past but it has just ended up with me writing out all the comments that come when you mouse over the variables anyway. I'll think about it again though and see if I can approach it a different way.
    I'd say just start by looking at the variables before the first drop down and ignore the rest for now. Default on all of those (except InterpolationBackTime because of your lower send rate) should be good though.

    What settings are you talking about here? Really you can't go too wrong with the default settings if you have a rigidbody you are trying to sync. (except change the InterpolationBackTime to match your send rate).
     
  31. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    181
    Thanks for your answers. The issue is that using Update it seems to have 'surges' and using FixedUpdate it seems to stutter looking like its only updating 10x/s . I have moved InterpolationBackTime to .3 and 0.4 and also reduced the lerp speed. I have also tried various options with using velocity or not. Is it right to use velocity AND position?

    The boat also has buoyancy added locally and this seems to make things worse (although if I remove it its still not 100% smooth.)
     
  32. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Redrag
    If you are changing the position locally, that'd add to the stuttering as Smooth Sync is probably trying to set the position at the same time that you are trying to set the position.
    Make sure you are only setting the position on owners (and Smooth Sync will handle setting the position on non-owners) (unless of course you aren't syncing Z position or something then you would be free to set the Z position on every networked instance of the object).

    If you confirm that only Smooth Sync is setting the position (and I'd probably just set WhenToUpdateTransform to Update as that's smoother) and it's still jittery, screenshot me your Smooth Sync settings and your Photon serialization rate and I'll take a look and see if I can find what's going wrong. OR if it's easy for you to send me your project, that's probably the best way for me to get a look at what might be going wrong.
     
  33. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    107
    Using this for movement:

    Code (CSharp):
    1. // Update is called once per frame
    2.         void Update()
    3.         {
    4.             if (MultiplayerManager.Instance.checkIfObjectIsMine(this.gameObject) && GetComponent<PlayerController>())
    5.             {
    6.                 thisTransform.Translate(Vector3.forward * Time.deltaTime * speed * speedMultiplier);
    7.                 //GetComponent<Rigidbody>().MovePosition(thisTransform.position + thisTransform.forward * Time.fixedDeltaTime * speed * speedMultiplier);
    8.                 //GetComponent<Rigidbody>().AddRelativeForce(thisTransform.forward * speed * speedMultiplier);
    9.             }
    10.  
    11.         }  

    Speed Boost code (dunno if it affects anything in sync ?)
    Code (CSharp):
    1. internal void speedBoost()
    2.         {
    3.             this.speedMultiplier = this.speedMultiplier * 1.3f;           //Change back to 1 after boost
    4.             //Set engine sound pitch
    5.             engineAudioSource.pitch = engineAudioSource.pitch + ((speed * speedMultiplier) / 10);
    6.             playSpeedBoostEffect();
    7.         }
    8.         internal void speedBoostReset()
    9.         {
    10.             this.speedMultiplier = this.speedMultiplier / 1.3f;           //Change back to 1 after boost
    11.             //Set engine sound pitch
    12.             engineAudioSource.pitch = engineAudioSource.pitch - ((speed * speedMultiplier) / 10);
    13.             stopSpeedBoostEffect();
    14.  
    15.         }
    Sync settings
    Unity_oqo761PDxS.png



    Yet the result
    KRn3oEhUOs.gif


    I do not get why I am having this kind of result I have been trying to solve this mystery since a week now tried pun transform view, classic view, self ccreated lag correction and compensation solutions via punobservable, PUN Simple Network Sync yet everything similar problem where even if I bring one car close to another in 1 window, its still away from it in 2nd window

    Detailed code/problem thread - https://forum.unity.com/threads/photon-pun2-non-rigidbody-lag-compensation-and-jittery-cars.912779/
     
  34. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    107
    I have also PMed you my project zip file to take a better look if you want to as I am now just clueless as a duck
     
  35. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @shubhank008
    Hi. I responded to you on discord already but I'm going to copy/paste my response here so others can see too. Let me know if you have more questions. :)

    So depending on your speed, things are just never going to line up perfectly. Check out a game like Fortnite and run next to someone and look at the two screens. It doesn't line up.
    [10:23 AM]
    You'll also see some jitter too. It's hard to notice in a real game and barely affects gameplay but even Fortnite has these issues. Most of networking is just hiding the fact that there's a limitation on how accurate two computers can be because of network lag.(edited)
    [10:24 AM]
    Even two instances of your game on the same computer, you have to tell it to send position, wait a frame for it to actually send, receive it on another frame, then apply it on the next frame. (Maybe one less frame, I forget the exact steps) I forget the math right now, but at like 60mph, you are still going to be "meters" (units) apart.(edited)
    [10:25 AM]
    You'd have to be constantly extrapolating into the future for it to line up, which then produces a whole host of other issues.
    [10:26 AM]
    As far as using Smooth Sync to line up better, try lowing InterpolationBackTime but try to keep it over 1/send rate(send rate is serialization rate in photon land?) or else you will be extrapolating a lot which may cause jitter.(edited)
    [10:27 AM]
    InterpolationBackTime specifically puts objects that amount of time in the past to buffer against lag spikes. So you could lag out for .1 seconds (the default InterpolationBackTime value) and still have buttery smooth super acurate representation of where the other player went.(edited)
    [10:31 AM]
    One thing I implemented for cars and following jitter in Smooth Sync is "Use Velocity Driven Syncing" under the Miscellaneous section of Smooth Sync settings. This will make it smoother, but it WILL be less accurate. Everything in networking is a trade off and it's just never going to be perfect because of the asynchronous limitations of networking.
     
    Rujash likes this.
  36. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Hi there, I was wondering how well this asset would sync an entire ragdoll (All of its limbs individually). Would that work well?
    I am using an active ragdoll system so I can't just sync animations - but if I disable the animator on all non-owners and just have the owner sync all bone transforms, could that work?
     
  37. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Vincent13122
    I would think syncing each limb individually would be a waste of networking resources. Depending on how important it is to your game, I would just sync the parent and let the limbs flop around.

    But if it's important to sync each limb in your game, I don't see why Smooth Sync wouldn't be able to sync your limbs. I just worry you are trying to sync hundreds of objects which no networking would handle that well. It's not a Smooth Sync limitation though, just a limitation of whatever networking system you are using. In fact I would think Smooth Sync would help with syncing them better because we offer a lot of ways to reduce the networking resources that are used for transformation syncing while still remaining buttery smooth.

    Let me know if you have any questions.
     
  38. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Thanks a lot, I'll buy it!
     
  39. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    What does Smooth Sync do? I just bought it thinking maybe it'll make my multiplayer easier to deal with. Does it sync my objects for me without me having to code it in? Can it also Sync animations if so? I haven't tried it yet but I'm getting ready to.
     
  40. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @theonerm2_unity
    Yes, just place a Smooth Sync onto your object and if it's a networked object, it will automatically sync transform (position, rotation, etc.) without you having to code anything.

    I don't know much about animations but if it's an object with a transform, it'll sync that. So if your animation is just moving objects with transforms, it should work for that.

    Let me know if you have any questions.
     
  41. comnie420

    comnie420

    Joined:
    Aug 5, 2020
    Posts:
    1
    Would this allow me to turn a game into a multiplayer game with no coding required? and if so what is the limit of players
     
  42. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @comnie420
    No this would not. You would still have to do a bunch of spawning code, game logic code, connection code, etc.
    Smooth Sync sends Transforms (position,rotation,etc.) and receives Transforms and makes it Smooth on every connected system.
     
    Rujash likes this.
  43. MM47

    MM47

    Joined:
    Sep 7, 2012
    Posts:
    25
    Hi @Fuestrine !
    SmoothSync works great for me, except the first second or so for any object. There's a visible jitter, as you can see on the Dragunov I'm dropping here:



    This happens for EVERY object in the first second of synchronization (the weapon isn't synchronized before it gets dropped - so SmoothSync starts syncing when it is dropped).
    After this initial jittery sync it's fine. (you can see me dropping the gun a second time and it is smooth)
    This happens regardless of settings (interpolation, extrapolation, smoothing). Nothing helps.
    Can someone help?
     
  44. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    Hi @MM47
    You are correct, this does happen for one second of movement after spawning.

    You can change line
    if (receivedStatesCounter < sendRate ||
    into
    if (receivedStatesCounter < sendRate / 2 ||
    or even a larger number than 2 if you want this for less time. (or you may be able to just comment out that first OR of the conditional all together? It may not even be needed this days now that I think about it)

    It was initially in there to get used to the average ping. When I put that lower, people were saying they had issues so I put it back to one second, but you can probably lower or maybe even take it out. I eventually want to make it so it's the first second after spawning and not the first second of movement but haven't had time.

    On a sort of side note but still related, you probably will want to make pools of objects that you just move into place instead of spawning them at runtime. This will get rid of CPU lag spikes at least a bit, but it depends on how much you are spawning for if it's even worth it to go down that dark road.

    Let me know how it goes. :)
     
    MM47 likes this.
  45. MM47

    MM47

    Joined:
    Sep 7, 2012
    Posts:
    25
    Thanks that fixed it :) I'll report back if there are any issues because of this change.
     
  46. MM47

    MM47

    Joined:
    Sep 7, 2012
    Posts:
    25
    @Fuestrine another issue which might or might not be related to SmoothSync. Although it seems to me its a smoothing/timing/interpolation issue.

    The player positions get desynchronized. You can see where they should be (bullet starting position) and where they appear. This happens only after the server has been running for several hours. Usually about 12-24 hours (not sure exactly). Is this a timing/interpolation issue?

    The reason I think this is SmoothSync is that you can see the player aiming and shooting correctly (synchronized). Aiming/shooting are done with my own code. The only thing out of sync is the player position which is handled by SS.

     
  47. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @MM47
    Soldat remake?! Did you see they are making a number two? One was/is such a great game. :)

    Anywho, there is an issue after running the game for 40+ hours or so due to floating point imprecision at higher numbers, but that's more of a jitter and less of a desync I would think. I have a fix for that but I haven't released it yet. I wouldn't expect the issue after 12 hours or so though anyway, but maybe. I can email it to you if you want to check it out. It basically resets the game time every 36 hours.
    Maybe keep this same idea in mind for your own code, floating point numbers just become inaccurate at higher numbers, I personally chose 131072 as my highest number but I stayed on the safer side. Unity variables don't have this built in so keep that in mind when using things like Time.RealTimeSinceStartup.

    There's also just the standard that Smooth Sync puts things SmoothSync.InterpolationBackTime amount of time in the past on purpose to cover up lag spikes. I don't think this is the main issue though as this doesn't happen at lower amounts of time that the game has been happening.
    Maybe in the same vein of this, if this issue is easily repeatable, try increasing TimeCorrectionSpeed and see if the issue still persists. It WILL jitter at higher values pretty quickly but keep going and see if you get the descyn after 12-24 hours.

    So two things to possibly try on your end:
    1. I have a fix if you think it's because Time.RealTimeSinceStartup is going too large and becoming imprecise. PM me your email or email me at the support address.
    2. Try increasing TimeCorrectionSpeed by a decent amount (I'd say crank it to like 3.0 to make sure) and see if the issue persists and it'll help me track down the issue.

    Let me know how it goes.
     
  48. Vauxvogh

    Vauxvogh

    Joined:
    Nov 29, 2017
    Posts:
    10
    Hey there Fuestrine! Ok this may have been answered but what should I do in this situation? When one of my players die and respawns, his dead body is like teleported and to his respawn spot. How do I stop it from following his body to his new spawn location? So basically its syncing the body while its respawning instead of just disappearing like it should then reappearing at the spawn location
     
  49. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    144
    I'm making a VR demo with SteamVR controlling the hands and mirror managing the networking. With mirror the players and items are synchronized but I'm having an issue that when the items are picked up they become parented to the SteamVR hand and the items visibility disappears from the clients that aren't holding the object. Each player can push the object about and other players can see the movement but when the object is picked up it disappears from others view until its dropped again. Would Smooth Sync fix this right out of the box with the way it handles rigidbodys or do you suppose it will take some coding?

    Thanks.
     
  50. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    590
    @Vauxvogh
    Can you rephrase that? I don't really know what you mean.

    Check out the Methods You May Need section at the bottom of our docs page:
    http://grabblesgame.com/smoothsync/

    Maybe you are just wanting to Teleport? There's also a Teleport example in the example scenes for each networking system.