Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    119
    @Fuestrine Thanks! I'll update now and give it a try... Do you foresee any issues with setting the lerp speed to 1? Wouldn't that make it jerky in other instances since, as I understand it, there would be basically no lerping happening? Or maybe I don't understand that bit... I was just going off of what the tooltips and code comments say. It made it sound like values closer to 1 get closer to no lerping. Obviously I would still want lerping to happen during regular movement.

    As for the editor performance... It could very well be my specific project. I have several hundred items (or more, didn't count :p) with the Smooth Sync component on them, so that could be the cause. Either way, it seems to work fine in built players, so I'm not too mad about it. :p
     
  2. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Jick87
    I definitely foresee issues with it being at 1 but there would still be lerping based on the speed of time if you are interpolating, there just won't be any easing (I more accurately rename the lerp variables to easing in the latestest updates). One pitfall is that going out of extrapolation will be probably jerky at 1 positionEasingSpeed. I've thought about separating the extrapolation and interpolation speeds but I could never think of a clean way to do it without adding a decent amount of performance overhead.

    OK, hundreds makes sense, lol. I'll do another round of optimization in a couple weeks anyway to see what I can do. I think it'll be fun to try to get into the very nitty gritty.
     
  3. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    119
    @Fuestrine One thing I thought about is some sort of "culling". Like, call the minimum amount of code on objects that are outside a certain range from the main camera? I guess you would still need to be calling some level of updating in case they are outside the range and then come inside the range or other events like that, but I guess maybe you could call stuff less often and maybe even just snap objects outside that range rather than lerp them. Not sure, just something I thought about. Maybe not even something that would make sense inside Smooth Sync. Just thinking out loud I guess. :p
     
  4. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Jick87
    That's not a bad idea. I already link some stuff to whatever the network distance culling thing that's built into Unity that I forget the name of right now. I'll see if I can put some other stuff away behind that wall too.
     
  5. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    115
    @Fuestrine Hey I've been using Smooth Sync and I very much like it! I discovered what I believe to be a bug though. If you disable the local player gameobject and re-enable it, it becomes jumpy for all other clients.
     
  6. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    11
    Hi @Fuestrine , I recently picked up SmoothSync but I'm having a bit of trouble with the teleport method. I'm trying to temporarily suspend smooth sync by disabling the script while my rigidbody isKinematic. When the object is no longer kinematic, I am using teleport() to resync their positions. The problem is that I briefly see the object in its previous position on the other clients before it then teleports to the correct position. Is there a better way to suspend syncing and re-enabling and forcing an update so that I won't see the "snap"? Could this be done with clearBuffer?

    I've tried using an rpc to wait for the teleport to be received but I'm still seeing the "snap". I've attached an example gif below. To me, it appears that it is, in fact, interpolating but just at a very high speed.

    Also, the teleport documentation appears to be outdated here as it no longer takes any variables. Is there updated documentation somewhere else? Can't find clearbuffer on there either.

    teleportProblem.gif

    EDIT: Literally, just tested clearBuffer and it appears to be working now! If you have a better solution though, please let me know!
    EDIT EDIT: Turns out I had a bug in the code where smoothsync wasn't being re-enabled properly. So I'm having same issue again.
     
    Last edited: Jul 3, 2018
  7. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    115
    I can say my issue is caused by the same as his except I haven't been able to fix it. My player is still jumpy.
     
  8. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @dadamsj1 @TCROC
    Thanks for bringing the issue to my attention with turning objects and scripts off and on. I see the issue on my end too and I'll let you all know when I'm done with the fix. Shouldn't be more than a few days.
     
  9. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    115
    @Fuestrine Thanks for checking it out. Ya just let me know when you have a fix in place. Thanks!
     
  10. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    11
    I had a bug in my code where smooth sync wasn't being re-enabled so I'm still having this issue. Please post here if you come up with a solution! Thanks for your help!
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @TCROC @dadamsj1
    I've sent a solution to your inboxes. Let me know if you have anymore issues and thanks again for bringing it to my attention.
     
  12. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    11
    Works perfectly for me! Thank you for your help!
     
  13. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    115
    @Fuestrine Thank you very much! It appears to have fixed things! I just tested it quick. I will be running it through a few more tests and will let you know if I run into any issues. Thanks again! :)
     
  14. Trainwiz

    Trainwiz

    Joined:
    Aug 25, 2015
    Posts:
    20
    @Fuestrine Just checking in since I saw there was a new update, were the fixes for very fast objects ever implemented/fixed?
     
  15. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Trainwiz
    I thought it was awhile ago but I just checked at 400 units a second and it's still a bit funkier than I would expect. I'll take another look this weekend and get back to you.
     
    Trainwiz likes this.
  16. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Trainwiz
    OK, it's looking much better now but you are pretty limited in use in order to get 400 units a second to look very smooth while also flying next to the unit that's going 400 units a second. I also have some worries about it being in the same spot and fighting it because at even a .02 difference in time between two computers, it's going to be off by 8 units.

    I can send you a version but I'm not sure if I'm going to put it on the store as I think it undoes a time fix for players who freeze up(not caused by SmoothSync, just in general) and fixing time when pausing (hopefully you don't need it, if so I can probably think of something that you'll have to call whenever you unpause). Or I'll have to add another confusing variable for an edge case. I can send you the new SmoothSync file and a screenshot of the changes so you can keep them going forward. It's a very small amount.

    Also, right now with the asset on the store, you can change your movement to use Time.realTimeSinceStartup and it will work but if you want to use Time.deltaTime for your movement, you'll want the new version.

    So, the major problem seems to stem from not updating in the same frame as the camera. So if you move your camera in Update, you'll want to put the WhenToUpdateTransform variable on Update too. Even using Time.time - lastFrameTime instead of Time.deltaTime produces a different result at 400 units a second since they are off by a tiny amount.

    You'll also want these settings for 400 units a second movement:

    TimeCorrectionSpeed at ~.0001
    This will correct your time slowly because even minor changes at 400 units a second will produce jittery objects. At this value, it'll do a tiny bit of sliding on each received message, not sure how it'll look when fighting in game but it's the best I've got and it's way better than what it was. You can also try it at 0, and use snapTimeThreshold to correct whenever it gets too far off, snapTimeThreshold will definitely jump the object though.
    At lower values for this variable though, your objects will be worse with highly variable pings (30, one send and 50 the next, then 10 the next, etc.).

    SendRate at ~1
    This sort of plays into the correction speed since it will correct the time on receives and the minor errors that result at 400 units a second. You can probably raise this if you lower TimeCorrectionSpeed. Feel free to take a look AdjustOwnerTime() as well and maybe you can up the send rate but only correct time by a certain amount every 10 receives or something.

    InterpolationBackTime at > SendRate
    This is just so it's interpolating all the time and not extrapolating between each send. You will definitely notice jumps at 400 units a second if it has to go between extrapolation and interpolation.

    PositionEasingSpeed at 1
    So there is no lagging behind.

    Let me know if have any questions or issues. I'm sure I was confusing at some point in there. :)
     
    Last edited: Jul 9, 2018
    Trainwiz likes this.
  17. SeasickRic

    SeasickRic

    Joined:
    May 16, 2017
    Posts:
    2
    Hi

    This is a great asset and the price is generous, so thanks very much (I have already reviewed with 5*!)

    One query:

    I have a networked player that is being Instantiated by NetworkManager, but most of the actual player stuff is then Instantiated by my code, meaning I can add a platform-specific version of the player. Part of that is the player's hand which I want to be seen by all the clients and sync'd (I suppose I could have gone with NetworkTransform here, but why use two technologies at once?) So, my code adds a Smooth.SmoothSync component to the 'parent' object and assigns the hand as the ChildObjectToSync.

    That didn't work, though, until I rewrote SmoothSync.cs so that I could call Awake() myself, having first set up the child-sync (I changed Awake() to OnAwake() and made Awake() call that - now I can call OnAwake() )
    So, have I missed a better way to do that? If not, could we have a public initialising method as part of the API, so I can upgrade in future without my 'hack' getting lost?

    Cheers for you help - also, sorry if I'm repeating a question as I haven't read through the whole forum.

    Ric
     
  18. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @SeasickRic
    Well that's the easiest feature request I've ever implemented. :)

    I think I'm just going to make Awake() public so people don't need to go searching for an initialization method that's already built into Unity. It'll probably show up on the store in about a week.

    Let me know if I misunderstood the request or if you have any other questions.
     
  19. Trainwiz

    Trainwiz

    Joined:
    Aug 25, 2015
    Posts:
    20
    @Fuestrine
    Sounds straightforward enough to me, send me that experimental version, and I'll try it out.
     
  20. contempt

    contempt

    Joined:
    Jul 31, 2012
    Posts:
    83
    @Fuestrine can Smooth Sync be used to sync blendshapes?
     
  21. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @contempt
    I don't know anything about blendshapes but Smooth Sync will work on any objects that have a transform that you move around on one game instance and you want it to sync to the other game instances.

    So like if you have a head object with a transform and the cheeks are objects with a transform, adding Smooth Syncs to them will sync them all.

    Basically, if adding Network Transform to the objects will sync it, then Smooth Sync will sync them, but better.

    Let me know if you have any other questions or if you buy it and have any issues.
     
  22. WTG-Bear

    WTG-Bear

    Joined:
    Jul 28, 2013
    Posts:
    3
    If I'm not using a rigidbody but have a velocity Vector3 for my player object, is it possible to use that for the smoothsync velocity instead?
     
  23. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @WTG-Bear
    You'll have to code it yourself, but it doesn't seem too difficult. Look at State.cs Serialize() and where it's checking if it should send velocity. Work your way through the project from there changing it to use your custom velocity. I try to comment everything so that other developers can read it. I'd be happy to answer specific questions though if you run into a problem.

    Keep in mind that you only need to send over velocity if you want to extrapolate. I also recently added the ability to extrapolate without sending velocity but it's only based on received positions so it's definitely not as good.
     
  24. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    74
    Hey @Fuestrine, today I decided to test out your plugin. And I've found an awful bug related to authority change. Please check the video.

    Here white buddies are Player objects controlled with WASD and little green buddy is a Non-Player object controlled with arrow keys.
    How to reproduce:
    I play as green buddy on the host. Then I switch to client and I can't control it. I ask for authority. Okay, now I can control it. I move it. Then I switch back to host, and now I can't control it again. I ask for authority again, and WHOA!! -- everything is desynchronized! Other client's object jumps to wrong position! It's a latest position where the host had authority before he lost it.
    Plugin version 2.02, I updated to latest 3.02, and the bug still exists. I can provide you my example project on demand.
     
  25. Lazdena

    Lazdena

    Joined:
    Aug 23, 2013
    Posts:
    5
    On that note though, I have been thinking about adding an optional delegate to the serialization/syncing. So if you implemented it in another behavior you could manually input the position, velocity, etc. Would allow decoupling of all the rigidbody and transform stuff and leave SmoothSync to just handle interpolation/extrapolation and network communication.

    I'm torn on it though, don't really plan on using extrapolation and it would take away from the "Plug and Play" nature of the plugin a bit.
     
  26. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @hottabych
    I couldn't find a way to automatically handle it, so you'll need to clear the buffer on the SmoothSync component after you switch owners. Look at the example in SmoothSyncExamplePlayerController.cs. I call the method CmdClearBuffer() in there.

    Let me know if you have any issues.
     
    Last edited: Jul 17, 2018
    hottabych likes this.
  27. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    74
    Hi again. If i transfer ownership from one client to another, this method works.
    Code (CSharp):
    1.     [Command]
    2.     void CmdSetAuth(NetworkIdentity identity)
    3.     {
    4.         var currentOwner = identity.clientAuthorityOwner;
    5.  
    6.         if (currentOwner == connectionToClient)
    7.         {
    8.             return;
    9.         }
    10.         else
    11.         {
    12.             if (currentOwner != null)
    13.             {
    14.                 identity.RemoveClientAuthority(currentOwner);
    15.             }
    16.             identity.AssignClientAuthority(connectionToClient);
    17.         }
    18.  
    19.         identity.GetComponent<NonPlayer>().RpcClearBuffer();
    20.     }
    But if I remove ownership on connected client, it still glitches despite CmdClearBuffer().

    It jumps back to position where authority was assigned.
    Code (CSharp):
    1.     [Command]
    2.     void CmdRemoveAuth(NetworkIdentity identity)
    3.     {
    4.         identity.RemoveClientAuthority(identity.clientAuthorityOwner);
    5.         identity.GetComponent<NonPlayer>().RpcClearBuffer(); //doesn't work
    6.     }
    I also tried to clear buffer on Server only, not sending RPC
    identity.GetComponent<NonPlayer>().smoothSync.clearBuffer();

    But it still glitches
     
    Last edited: Jul 18, 2018
  28. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @hottabych
    Thanks for bringing the issue to my attention. I'll check it out and get back to you.
     
  29. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @hottabych
    Alright, it looks all fixed for me now. Let me know if you have anymore issues.

    Change clearBuffer() in SmoothSync.cs to look like this:
    Code (CSharp):
    1. public void clearBuffer()
    2.         {
    3.             stateCount = 0;
    4.             firstReceivedMessageZeroTime = 0;
    5.             restStatePosition = RestState.MOVING;
    6.             restStateRotation = RestState.MOVING;
    7.             positionLastFrame = Vector3.zero;
    8.             rotationLastFrame = Quaternion.identity;
    9.         }
     
  30. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    74
    Thanks, yes, now it fixed. Don't forget to put it into next plugin update.
    Also, this ClearBuffer() call is not evident. I wouldn't ever guess without your hint. I think you should mention it in readme.
     
  31. LegalSin

    LegalSin

    Joined:
    Dec 27, 2016
    Posts:
    24
    @Fuestrine :D you rock man! It was easy for me to do all the necessary modifications to fit this into my game :D but tbh you among all other sellers on this store are the best. GJ keep it up!
     
  32. Roamer79

    Roamer79

    Joined:
    Oct 25, 2016
    Posts:
    33
    How about the ability to select if I want to sync local position instead of world? The ability to sync several child objects would also be very handy.
     
  33. Roamer79

    Roamer79

    Joined:
    Oct 25, 2016
    Posts:
    33
    Is there any updated documentation?? I updated my smoothsync and am now having jitter issues on rotation. Is like its snapping but snapping rotation is at 0. I swear it was perfect on the previous version I had.

    Also, the default Qos channel is 'unreliable'. Is that the recommended? What about the Qos 'state' channel?
     
  34. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Roamer79
    I'm not seeing the rotation issues in the example scene. Is it 2D or 3D? Rigidbody or no rigidbody? What is the "snapping rotation at 0", is it the z axis rotational value? Screenshots of your object and movement code is probably the best way for me to get the full picture so I can recreate the issue on my end.

    Check out the example scene for how to sync child objects. SmoothSyncPlayerPrefab is the object with children. It'll use local position for children and world position for parents automatically but if you want to change it, it's in SetPosition() and GetPosition().

    I recommend the unreliable channel, I've never had any problems with it. The "state" channel seems like it would work but that's not the channel I normally use.
     
    Last edited: Jul 20, 2018
  35. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Lazdena
    I'm not entirely sure what you are trying to do but let me know if you have any questions.

    @hottabych
    Great suggestion. I'll place the few methods people might need for general use in the readme and on the main documents page.

    @LegalSin
    Thanks! Always great to hear.
     
    Last edited: Jul 21, 2018
  36. Roamer79

    Roamer79

    Joined:
    Oct 25, 2016
    Posts:
    33
    Thanks for getting back! No its just a helicopter without a rigidbody. Syncing transform and rotation only. So I just tried copying the smooth sync settings from the smoothsync demo scene prefab. Same problem. However I lowered the "rotation easing speed" from .85 to .1 and it was syncing smooth. Does that sound right to you? What exactly does that setting do? Is it ok to have it all the way down at .1 or am I probably lagging it?

    I mean, I can send you the mover code but it is perfectly smooth as host, was smooth on the old version of smooth sync, is almost smooth using Network Transform (but who wants to use that junk!).

    Also, I have been syncing my enemies with a custom sync script using syncvars. It actually works really really well but I have been reading around and some people have mentioned it is a costly exercise. What do you think about this approach being the expert here??

    Thanks again for taking time to answer questions!!
     
  37. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Roamer79
    I'm not seeing any problems with default settings with no rigidbody rotating in the example scene either.

    My movement code:
    Code (CSharp):
    1. Vector3 oldRotation = transform.rotation.eulerAngles;
    2. Vector3 newRotation = new Vector3(oldRotation.x, oldRotation.y, oldRotation.z + 200 * Time.deltaTime);
    3. transform.rotation = Quaternion.Euler(newRotation.x, newRotation.y, newRotation.z);
    I would say it's unusual to need RotationEasingSpeed to be less than .85 but I don't know your exact circumstances. At .1 it will definitely be lagging behind a bit. That variable makes the object move that amount (in percent) towards it's target destination.

    My guess is that the "Rotation Easing Speed" used to be required to be lower (back in 2.0) so it was kind of hiding some things that might be off in the background.

    I don't know much about syncvars unfortunately. I've never used them in any of my projects.

    If none of that information helps, the next best step would be sending me your movement code and a screenshot of your object so I can try to replicate the issue on my end. Or you can try to replicate it in the stripped down example scene to see what may be going wrong.
     
  38. contempt

    contempt

    Joined:
    Jul 31, 2012
    Posts:
    83

    Thanks for the reply. I already own Smooth Sync and your wonderful NAT traversal asset. The values I'm looking to sync are just floats. I'm using ARKit and the iPhone X to be able to send facial expressions to an Apple TV 4k based experience. Alternatively if I could send a dictionary containing pairs of strings (blendshapes name) and floats for the blendshapes that would be great too. It sounds like it should be possible I'll spend some time on this and let you know if I need any further assistance. Thanks!
     
  39. MicahDuck

    MicahDuck

    Joined:
    Nov 25, 2016
    Posts:
    7
    @Fuestrine hi,

    I'm currently using smooth sync and I have a problem where the character will sometimes jitter a small distance back and forth sporadically (gyazo below). Only the other players can see this and not the actual player himself. I thought this was perhaps because the character had velocity on the other players clients but setting its velocity to zero didn't do anything. Was wondering if you had any idea that could be causing it and was looking for help. Thanks!

    transform position GIF - https://gyazo.com/ed0e74e6caf2d3a0d91ff8e4953a6d7a

    transform smooth sync setings - https://gyazo.com/e7fe98ec9c9c3397ea6a0d7ec4819462
     
  40. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @MicahDuck
    Does this happen when you are moving or at rest?

    My first thought is that you are trying to move the object on every game instance instead of just the owner. The non-owners will be getting their position set from SmoothSync so you won't want to change the position on those.
     
  41. mwg3

    mwg3

    Joined:
    Apr 8, 2018
    Posts:
    36
    Hi @Fuestrine , together with my friend, we want to create a project. He bought your asset some time ago but there was no chance to test it yet. Now it's good time. Can you say what are the best settings for a player who is supposed to fight monsters? I want to see the best settings in screenshot, thank you in advance
     
  42. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @mwg3
    Start by making sure you have the latest version from the Asset Store.

    It's hard to say what the best settings are though. There's a lot of nuances in what kind of behavior you want and a lot of trade offs. Say if you want a faster reaction, but now you are more susceptible to lag spikes and if you are leaving it up to the players to be the servers, it could ruin the experience for everyone in the game.

    Overall though, I say start with the default settings except you can probably lower interpolationBackTime to .05 for a faster reaction time. Second, you can start raising the positionEasingSpeed and rotationEasingSpeed variables to get an even faster reaction time but you'll have to see what or if there's a limit in your specific scenario.

    Let me know if you have more questions.
     
  43. mwg3

    mwg3

    Joined:
    Apr 8, 2018
    Posts:
    36
    Yes, i have version 3.03. Tell me, what settings are the best for survival game?
    That is my config
    With send rate 30 and when to update 'update' @Fuestrine
     

    Attached Files:

    • set.png
      set.png
      File size:
      20.5 KB
      Views:
      67
    Last edited: Jul 28, 2018
  44. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @mwg3
    If it's like a non-competitive survival game, I say just use the default settings. They'll give you a nice well rounded experience of fast reaction and a smooth experience. You can reset to the default settings by removing and adding the script again, or by clicking the gear to the top right of the component and clicking "reset".

    If you want a faster reaction time you can:
    1) Lower interpolationBackTime to .05.
    2) Start raising the positionEasingSpeed and rotationEasingSpeed variables but you'll have to see what or if there's a limit in your specific scenario for that.
     
  45. mwg3

    mwg3

    Joined:
    Apr 8, 2018
    Posts:
    36
    @Fuestrine Okay, thank you :) My last question is.. what is difference between Limited and unlimited?
     
  46. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @mwg3
    Setting extrapolation to Limited will will allow you to limit extrapolation by time or distance.

    Setting extrapolation to Unlimited will will allow you to extrapolate forever.

    Some people might want an extrapolation limit so that things don't get too crazy if you stop receiving network information.
     
  47. Lone-Coder

    Lone-Coder

    Joined:
    Sep 8, 2012
    Posts:
    59
    Thank you for the great asset. I'm using it over at https://legendstudio.com/never-split-the-party/

    I'm getting the following exception about 100x a day using Smooth Sync 3.03. It only seems to happen on the server. Probably during game cleanup.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Smooth.SmoothSync.HandleSyncFromOwnerToServer (UnityEngine.Networking.NetworkMessage msg) (at C:/Users/bryan/Documents/Games/Experimental/Networked WebGL/Assets/Extensions/Smooth Sync/Smooth Sync Asset/SmoothSync.cs:1853)
    3. UnityEngine.Networking.NetworkConnection.HandleReader (UnityEngine.Networking.NetworkReader reader, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:469)
    4. UnityEngine.Networking.NetworkConnection.HandleBytes (System.Byte[] buffer, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:425)
    5. UnityEngine.Networking.NetworkConnection.TransportReceive (System.Byte[] bytes, Int32 numBytes, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:576)
    6. UnityEngine.Networking.NetworkServerSimple.OnData (UnityEngine.Networking.NetworkConnection conn, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkServerSimple.cs:460)
    7. UnityEngine.Networking.NetworkServerSimple.HandleData (Int32 connectionId, Int32 channelId, Int32 receivedSize, Byte error) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkServerSimple.cs:384)
    8. UnityEngine.Networking.NetworkServerSimple.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkServerSimple.cs:247)
    9. NATTraversal.NetworkManager+<>c.<Update>b__85_0 (NATTraversal.ExternalServer server)
    10. System.Collections.Generic.List`1[NATTraversal.ExternalServer].ForEach (System.Action`1 action) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:361)
    11. NATTraversal.NetworkManager.Update ()
    12.  
    13.  
    14.  
    15. Current Level = 0
    16. Current Room = Start
    17. Server = True
    18.  
    19. Veiko Fighter Unknown *
    20. Goerk Fighter Unknown
    21. HP Compaq 6005 Pro MT PC (Hewlett-Packard) DESKTOP-1VOQKIS Desktop 0b391d94da4b300285e02980a814c39460845142
    22. Windows 10  (10.0.0) 64bit, , 8179, 4x AMD Phenom(tm) II X4 B95 Processor
    23. 1680x1050 96dpi FullScreen True, NVIDIA GeForce GT 1030, NVIDIA vmem: 1982 Max Texture: 16384
    24.  
    25. Scene Roguelike, Unity Version 5.6.6f2

    Here's the code. The exception is thrown at the first if statement, so the null ref has to be one of networkState, smoothSync, or netID.

    Code (CSharp):
    1.         /// <summary>Receive owner's State on the host and send it back out to all non-owners.</summary>
    2.         /// <remarks>
    3.         /// This static method receives incoming State messages for all SmoothSync objects and uses
    4.         /// the netID included in the message to find the target game object.
    5.         /// Calls addState() and SendStateToNonOwners() on the target SmoothSync object.
    6.         /// </remarks>
    7.         static void HandleSyncFromOwnerToServer(NetworkMessage msg)
    8.         {
    9.             NetworkState networkState = msg.ReadMessage<NetworkState>();
    10.  
    11.             // Ignore all messages that do not match the server determined authority.
    12.             if (networkState.smoothSync.netID.clientAuthorityOwner != msg.conn) return;
    13.  
    14.             // Always accept the first State so we have something to compare to. (if latestValidatedState == null)
    15.             // Check each other State to make sure it passes the validation method. By default all States are accepted.
    16.             // To tie in your own validation method, see the SmoothSyncExample scene and SmoothSyncExamplePlayerController.cs.
    17.             if (networkState.smoothSync.latestValidatedState == null ||
    18.                 networkState.smoothSync.validateStateMethod(networkState.state, networkState.smoothSync.latestValidatedState))
    19.             {
    20.                 networkState.smoothSync.latestValidatedState = networkState.state;
    21.                 networkState.smoothSync.latestValidatedState.receivedOnServerTimestamp = Time.realtimeSinceStartup;
    22.                 networkState.smoothSync.adjustOwnerTime(networkState.state.ownerTimestamp);
    23.                 networkState.smoothSync.SendStateToNonOwners(networkState);
    24.                 networkState.smoothSync.restartLerping();
    25.                 networkState.smoothSync.addState(networkState.state);
    26.             }
    27.         }
    What's the proper fix here?

    Thanks again.

    Bryan
     
  48. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    328
    @Lone-Coder
    I just tried a bunch of joining and leaving of multiple clients and dedicated server and not dedicated server and I couldn't replicate the issue.

    Code (CSharp):
    1.  // Ignore all messages that do not match the server determined authority.
    2. if (networkState != null && networkState.smoothSync && networkState.smoothSync.netID &&
    3.                 networkState.smoothSync.netID.clientAuthorityOwner != msg.conn) return;
    That should handle all null exceptions but it's a bit more performance heavy checking every single null. It probably won't matter if you aren't syncing a bunch of objects, but if you can narrow it down to which one is nulling out on you, it would probably be for the best.

    If I had to guess, I would guess it's networkState.smoothSync that is nulling out.

    Let me know what you find or let me know how else to replicate the issue or if you have any questions.
     
  49. Lone-Coder

    Lone-Coder

    Joined:
    Sep 8, 2012
    Posts:
    59
    K. I'll give it a try and let you know. It's probably got something to do with me deleting network objects via RPC rather than NetworkServer.Destroy.
     
  50. mwg3

    mwg3

    Joined:
    Apr 8, 2018
    Posts:
    36
    @Fuestrine F***:( It's me again.. I had default config with 'Lower interpolationBackTime to .05.
    2) Start raising the positionEasingSpeed and rotationEasingSpeed variables but you'll have to see what or if there's a limit in your specific scenario for that.' and this doesn't work for mobs. (this script only works for players but super slowly ). Every one of my server saw monsters that were in other locations..
     
    Last edited: Aug 2, 2018