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. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Should work fine, but you may need to change your Transform Source under Miscellaneous to Server so that the server has control instead of the owning client if your objects are not actually owned by the server.

    If you're still experiencing jitters I'd probably need to know more about your implementation or see a video of exactly what you're experiencing. If everything is working correctly there should be no jittering though.
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @SixDimensional Seems like you would want to get rid of everything from that script except the bit that sets the position equal to the camera position on owners:
    Code (csharp):
    1.  
    2. if (photonView.IsMine && isUser)
    3. {
    4.   var trans = transform;
    5.   var mainCameraTransform = mainCamera.transform;
    6.   trans.position = mainCameraTransform.position;
    7.   trans.rotation = mainCameraTransform.rotation;
    8. }
    9.  
    And then let SmoothSync do the actual network syncing.
     
  3. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yeah, this is a real sore point for me. I really do want to implement something for client-side prediction eventually, but as you pointed out it tends to differ for each project. The only real tip I can give you is that you'll probably want temporarily disable Smooth Sync on the "owning" client whenever they perform some action so that you can do your client-side prediction (whatever that may be). Then after some time, you'll want to clearBuffer and re-enable SmoothSync so it switches back to syncing from the server. You may also want modify Smooth Sync somehow to smoothly interpolate between the client-side predicted position and the new stuff coming in from the server after you re-enable. Obviously I'm being a little vague on the details because if I had it all figured out I would have already implemented it! I hope that at least helps you get started figuring something out though.
     
  4. SnooksV3

    SnooksV3

    Joined:
    Dec 11, 2018
    Posts:
    11
    Thanks for the response.

    Yea I think it's actually a Unity camera issue. My game is physics based and the player camera is a child object of the player because it's an FPS. My camera is jittering when close to other objects because my physics are running in fixed update, and my camera is lagging behind or something. Which I don't understand because it's literally attached to the player... It's actually always jittering but you can't tell until you're close to something.

    I've tried 20 different ways of setting up a camera up to get rid of this. Custom interpolating(linear lerping), detaching the camera from the player object etc. Nothing works.

    It's a widely known issue and nobody has yet come up with the right solution for an FPS camera. Have you overcome this yourself?
     
  5. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    123
    Hi,

    I have the following 2 questions:

    a) Does it support piggybacking?
    I would like to send some custom bits (8 bits) on top of the data that already gets sent, so I do not need to send them extra and have the header bigger than the actual data.

    b) Is it possible to stop sending position/rotation when they are not changed?
     
  6. Japsu

    Japsu

    Joined:
    Jan 17, 2018
    Posts:
    14
    Thanks for the answer!
    I'll have a go with your suggestions, and check back with my results (if I remember to :p) to help others with the same issue.
     
  7. jonmey

    jonmey

    Joined:
    Mar 26, 2021
    Posts:
    1
    Hi

    Good asset in general but having some strange behavior when using FixedUpdate for "When to Update Transform".

    I'm using Mirror and my Player object is set up like this:

    upload_2021-5-20_0-14-51.png

    where the parent ("Player") has a NetworkIdentity, a Rigidbody2D, a simple network script and the SmoothSync script. The child ("Model") has a player movement script, BoxCollider2D, SpriteRenderer, Animator etc.

    If I set "When to Update Transform" to Update, everything works perfectly. But if I change it to FixedUpdate, transforms no longer get synced between players. A workaround however seems to be setting the childObjectToSync as the parent itself ("Player"). It then runs perfectly fine, but you get an error message in console about needing to have a SmoothSync script with a blank childObjectToSync (yes, I've read the readme). So finally, with two SmoothSync scripts on the parent with one having childObjectToSync set to itself, it runs using FixedUpdate without errors.

    1. Why does this differ so much between the "When to Update Transform"-method is used? Is this intentional?
    2. Why does it throw an error about needing another instance with childObjectToSync unset when it actually runs fine?
    3. Why does childObjectToSync have to be set to the parent itself? This doesn't make sense.
     
  8. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    37
    I don't believe your asset is as easy as you claim!

    You're saying every object I want to be responsive in network, synced across clients, I only need to add smoothsync script?

    Does smoothsync work for player controlled objects? Is there a tutorial on that, or just for inanimate/autonomous objects? Does smoothsync work with both P2P and server authoritative? Do you have a comparison video of smoothsync collisions on P2P vs server authoritative?

    Does noble sync come with smooth sync?
     
  9. SnooksV3

    SnooksV3

    Joined:
    Dec 11, 2018
    Posts:
    11
    This asset does not work as intended. It does not lerp locally and has unwanted effects when instantiating (Networked) objects while giving them force.

    Beyond that, the support is pretty bad.

    Please let me know how I can go about getting a refund please.
     
  10. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @SnooksV3 Smooth Sync is not designed to lerp locally, it only controls the networked position. How you move the character locally is entirely up to you. The issue with adding force while instantiating may be real, I'd have to test, but I know people have used Smooth Sync for bullets and missiles and similar things in the past so I would expect it to work.

    If you would like a refund you can send your invoice number to assetsupport@noblewhale.com
     
    cpasjuste likes this.
  11. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Smooth Sync works for all of those scenarios. Collisions will not work well though unless all of the colliding objects have the same owner, which generally means server authoritative. Smooth Sync does not have client-side prediction built in though so you will still have to solve that for a good server authoritative solution. Smooth Sync only handles syncing from the server to the client in a server authoritative setup so you'll probably need to implement some form of client-side prediction so that the clients don't experience delay between input and movement.

    Noble Connect does not come with Smooth Sync.
     
  12. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    There is nothing built in for piggybacking but you are welcome to extend the code to send whatever you want. In the State class you should see Serialize and Deserialize methods. You can add extra stuff at the ends of those methods to write/read whatever you want.

    Position and rotation are automatically not sent if they don't change. There is a built in "rest" system that stops sending whenever the object goes to rest.
     
  13. zenforhire

    zenforhire

    Joined:
    Nov 5, 2012
    Posts:
    65
    Integrated with unet 1.6. It is updating the client. It is a Camera aboard a moving vehicle.
    But i now get motion sickness and head aches with movement. If I look closely, it seems to be moving the image slightly backwards and stuttering every so often. What settings to play with to minimize the stuttering.
     
  14. zenforhire

    zenforhire

    Joined:
    Nov 5, 2012
    Posts:
    65
    Does Smooth Sync allow adding transform children at runtime? Does it allow removing the same transform child a little bit later. Can you explain the sequence needed. Consider dropping a bomb from a plane. The Bomb prefab will already have a SmoothSync component. Add to wing as child. Drop bomb. Remove the transform Child.
     
  15. errorsevendev

    errorsevendev

    Joined:
    Sep 29, 2016
    Posts:
    8
    Hi I've been using Smooth Sync for years in my UNET based game "Ships Of Glory". Its works great.
    I am now upgrading to Mirror and having a hard time getting it to work.

    What Im stuck at is changing player authority, I used to use this for UNET and works fine:

    Code (CSharp):
    1. GameObject newPlayer = Instantiate(spawnPrefab, spawnTransform.position, spawnTransform.rotation);
    2. NetworkServer.ReplacePlayerForConnection(connectionToClient, newPlayer);//, playerControllerId);
    3. newPlayer.GetComponent<Player>().Setup(userName, country, pirate, ship, shipData, false, side);
    4. NetworkServer.Destroy(this.gameObject);
    Now though I end up with: "Smooth Sync: Cannot find target for authority change."

    I've installed SmoothSyncMirror.unitypackage.
    I have tried adding in a SmoothSyncMirror.AssignAuthorityCallback(connectionToClient, newPlayer.GetComponent<Player>().netIdentity, true) to no benefit but Im unsure where to put it and what parameters to use?

    Im using Unity 2019.4.28f1, Smooth Sync 3.34 & Mirror 40.0.9
    Any help would be greatly appretated!
     
    Last edited: Jun 24, 2021
  16. XuanXuan4Ni

    XuanXuan4Ni

    Joined:
    Jul 10, 2021
    Posts:
    1
    Hi,

    I am developing multiplayer 2D game in PUN2. I have a little problem that My 2D sprite is flipping when I change its scale.x. I want it when it moves left to right and the sprite "instantly" snaps same direction. I have tried setting "scale easing speed" to 1 and setting "snap scale threshold" to really low value but above zero. Its still not working. How can I do that?
     
  17. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yeah this should work. You will probably need an extra Smooth Sync component on the parent in addition to the one on the bomb. Disable the SmoothSync component on the bomb when it is attached, and enable it when it is separate. And conversely disable the extra Smooth Sync component on the parent when the bomb is detached, and enable it when attached. When you want the bomb to be synced as a child you would do something like:

    Code (CSharp):
    1. extraParentSmoothSync.SetObjectToSync(theBomb);
    2. extraParentSmoothSync.enabled = true;
    3. bombSmoothSync.enabled = false;
    And then to drop the bomb:

    Code (CSharp):
    1. extraParentSmoothSync.SetObjectToSync(null);
    2. extraParentSmoothSync.enabled  = false;
    3. bombSmoothSync.enabled = true;
    But honestly the much easier solution is to just have two copies of the bomb, one that is always attached the plane and gets hidden when dropped, and another that is independent of the plane and just spawned at location and dropped when needed so you can avoid this issue entirely.
     
  18. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    You should not need to call that method manually. Everything should work automatically as long as you have Smooth Authority Changes enabled on the Smooth Sync component.
     
  19. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    It seems like you've got the right idea. I'm not sure why it's not working for you. I just made a quick test that flips the scale of an object on keypress with the scale snap threshold set to .1 and it seems to work as expected. Are you sure you've got the latest version of Smooth Sync? I believe there was a similar issue fixed not too long ago. Make sure to import the SmoothSyncPUN2.unitypackage after updating to update the PUN related stuff.
     
  20. gregacuna

    gregacuna

    Joined:
    Jun 25, 2015
    Posts:
    59
    I'm a game designer using Playmaker with Unity to create games, but having real trouble doing multiplayer with Photon 2. My question is whether your asset would help me avoid the Photon setup for the game objects I needed synced across the network.
     
  21. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    85
    I know how to use playmaker if you want I can help you with your problems.
     
  22. nnichael

    nnichael

    Joined:
    Mar 13, 2013
    Posts:
    5
    Hey! Just got this, I may not know what I'm doing, but putting the SmoothSyncPUN2 script on objects throws this error, and nothing is synced on play.

    NullReferenceException: Object reference not set to an instance of an object
    Smooth.SmoothSyncPUN2.getPosition () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:1411)
    Smooth.SmoothSyncPUN2.sendState () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:806)
    Smooth.SmoothSyncPUN2.OnPhotonSerializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:2077)
    Photon.Pun.PhotonView.SerializeComponent (UnityEngine.Component component, Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:557)
    Photon.Pun.PhotonView.SerializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:521)
    Photon.Pun.PhotonNetwork.OnSerializeWrite (Photon.Pun.PhotonView view) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1721)
    Photon.Pun.PhotonNetwork.RunViewUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1650)
    Photon.Pun.PhotonHandler.LateUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:171)

    Anyone have any ideas?
     
  23. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Not really. All Smooth Sync will do is sync the objects. Spawning them and setting everything up doesn't change.
     
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I just tested in 2020.3 with the latest PUN 2 and Smooth Sync from the Asset Store and I'm not getting this error. Does the SmoothSyncExampleScenePUN2 scene work for you?
     
  25. nnichael

    nnichael

    Joined:
    Mar 13, 2013
    Posts:
    5
    It does. It's also odd because it does work on my main scene... sometimes. It'll work, then I make some small changes to the code (my own classes), then it'll throw that error on smoothsync.
     
  26. LastChaos

    LastChaos

    Joined:
    Dec 9, 2013
    Posts:
    39
    Hi, I'm using SmoothSyncMirror and when used in conjunction with a DistanceInterestManagement on the server I get an error and crash on client side. As I understand it, this is due to the fact that the server manages to send the object data at the time of its removal on the client and the client receives data about an object that he no longer has. What is the best way to fix that?
    upload_2021-8-4_22-21-47.png
     
    Last edited: Aug 4, 2021
  27. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    Thanks for the help! Unfortunately, my object pool is server side. They are disabled after instantiating, but once enabled on the server. Will spam the error below, until I actually spawn the object for use.

    Code (CSharp):
    1.  
    2. SpawnStateException: Object is not spawned
    3. MLAPI.NetworkObject.GetObservers () (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkObject.cs:182)
    4. Smooth.SmoothSyncMLAPI.sendState () (at Assets/Imported/Dependencies/Smooth Sync/MLAPI/Smooth Sync Asset/SmoothSyncMLAPI.cs:913)
    5. Smooth.SmoothSyncMLAPI.FixedUpdate () (at Assets/Imported/Dependencies/Smooth Sync/MLAPI/Smooth Sync Asset/SmoothSyncMLAPI.cs:792)
    6.  
    I bug fixed by checking IsSpawned in the fixed update, though I cached it in Network Start and disable

    MLAPI team may add OnDespawn method
     
    Last edited: Aug 5, 2021
  28. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    I also encountered this error on MLAPI when teleporting the player object on the server with the method

    Code (CSharp):
    1. smoothSync.teleportAnyObjectFromServer(spawnPosition, Quaternion.identity, Vector3.one);
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2.   at Smooth.SmoothSyncMLAPI.addTeleportState (Smooth.StateMLAPI teleportState) [0x000ac] in /Users/cosmicstudios/Beyonders/Source/Beyonders - Client & Game/Assets/Imported/Dependencies/Smooth Sync/MLAPI/Smooth Sync Asset/SmoothSyncMLAPI.cs:1878
    3.   at Smooth.SmoothSyncMLAPI.TeleportServerRpc (UnityEngine.Vector3 position, UnityEngine.Vector3 rotation, UnityEngine.Vector3 scale, System.Single tempOwnerTime) [0x00193] in /Users/cosmicstudios/Beyonders/Source/Beyonders - Client & Game/Assets/Imported/Dependencies/Smooth Sync/MLAPI/Smooth Sync Asset/SmoothSyncMLAPI.cs:1825
    4.   at Smooth.SmoothSyncMLAPI.TeleportServerRpc__nhandler (MLAPI.NetworkBehaviour target, MLAPI.Serialization.NetworkSerializer serializer, MLAPI.Messaging.__RpcParams rpcParams) [0x000a3] in <e57f9a9eb26b4977bf1dad3170e81bd4>:0
    5.   at (wrapper delegate-invoke) System.Action`3[MLAPI.NetworkBehaviour,MLAPI.Serialization.NetworkSerializer,MLAPI.Messaging.__RpcParams].invoke_void_T1_T2_T3(MLAPI.NetworkBehaviour,MLAPI.Serialization.NetworkSerializer,MLAPI.Messaging.__RpcParams)
    6.   at MLAPI.NetworkManager.InvokeRpc (MLAPI.Messaging.RpcFrameQueueItem queueItem) [0x0011a] in /Users/cosmicstudios/Beyonders/Source/Beyonders - Client & Game/Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkManager.cs:1145
    7.  
    Sorry to bombard you guys. Thanks for the great asset!!!
     
  29. Steamc0re

    Steamc0re

    Joined:
    Nov 24, 2014
    Posts:
    144
    @thegreatzebadiah
    Getting slew of errors after updating to latest, from 3.34
    *edit* Removed extrapolation and it cleared the errors. Using PUN2.

    Code (CSharp):
    1. transform.position assign attempt for 'Player(Clone)' is not valid. Input position is { -Infinity, Infinity, Infinity }.
    Code (CSharp):
    1. QuaternionToEuler: Input quaternion was not normalized
    2. UnityEngine.Quaternion:get_eulerAngles ()
    3. Smooth.SmoothSyncPUN2:applyInterpolationOrExtrapolation () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:1149)
    4. Smooth.SmoothSyncPUN2:SmoothSyncUpdate () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:727)
    5. Smooth.SmoothSyncPUN2:Update () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:693)
    Code (CSharp):
    1. QuaternionToEuler: Input quaternion was not normalized
    2. UnityEngine.Quaternion:get_eulerAngles ()
    3. Smooth.SmoothSyncPUN2:applyInterpolationOrExtrapolation () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:1149)
    4. Smooth.SmoothSyncPUN2:SmoothSyncUpdate () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:727)
    5. Smooth.SmoothSyncPUN2:Update () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:693)
    Code (CSharp):
    1. Assertion failed on expression: 'CompareApproximately(SqrMagnitude(result), 1.0F)'
    2. UnityEngine.Quaternion:Euler (UnityEngine.Vector3)
    3. Smooth.SmoothSyncPUN2:applyInterpolationOrExtrapolation () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:1159)
    4. Smooth.SmoothSyncPUN2:SmoothSyncUpdate () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:727)
    5. Smooth.SmoothSyncPUN2:Update () (at Assets/Smooth Sync/PUN2/Smooth Sync Asset/SmoothSyncPUN2.cs:693)
     
    Last edited: Aug 11, 2021
  30. Cuttlas-U

    Cuttlas-U

    Joined:
    Apr 11, 2017
    Posts:
    38
    Hello,
    I wanted to buy this asset but was not sure if it can help for what I need ,
    I'm using unity transport package(low level) , so I'm sending every thing with my own code ,
    not using either Mirror or MLAPI ,
    can i still some how convert this package to help me in that case ?
    or can i have a little help to do it after i buy the asset ?
    Thanks a lot
     
  31. 13E12K

    13E12K

    Joined:
    May 4, 2014
    Posts:
    20
    Hi there,

    I am using Smoothsync almost at default settings.

    On sever-side all player behave normal. However, on client-side, when I have the client showing 50-60 FPS all players on client jitters. Lowering the FPS to around 25-30 FPS makes everything fine at client again.

    It is not a camera or camera-follow issue, since even camera standing still on client the jitter is present.

    I have tried the "When to update the transform" option but same result. Is there any way to avoid the jitter even at high FPS on client side?
     
    Last edited: Aug 31, 2021
  32. gotonightmare_unity

    gotonightmare_unity

    Joined:
    Sep 14, 2020
    Posts:
    4
    Having problem aswell with Mirror and SmoothSyncMirror.
    How to replicate: just spawn, move and destroy a lot of objects, client + server.
    `NetworkClient: recieved Message was too short`
     
  33. thangnh111

    thangnh111

    Joined:
    Aug 4, 2020
    Posts:
    21
    Does it work with client side prediction?
     
  34. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    There is nothing built in for client-side prediction but you are free to implement your own solution on top of Smooth Sync by settings the Transform Source to Server and temporarily disabling the component on the owning client when you do your prediction stuff.
     
  35. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    Looks like this is a bug in Smooth Sync. Should be pretty straight-forward to fix though, I'll try and get it in the next release. Thanks for reporting it.
     
    Last edited: Sep 25, 2021
  36. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    289
    Hello @Zebadiah
    Thanks for this great asset. I have a problem now. I have some colliders arround and when my networked object collide with these sounds play. No problem when I am owner of object. I can hear sounds. However when I am not owner, I cannot hear sounds. İt means it doesnt collide with other objects...
    How can I solve this?
    By the way, I dont want to use velocity driven sync...
     
  37. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    I'd probably suggest using an rpc from the owner to everyone to play the sounds. Physics interactions like that are tricky with networking, generally it will only work 100% correctly if all the interacting objects have the same owner. Looks like in your case it's working how you want on the owner though so just send an rpc from there and call it a day :)
     
    Last edited: Sep 24, 2021
  38. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    289
    Thanks for the answer
    Other objects are static objects at the scene. They have no owner. I have a ball and its owner are changing. So WHen I am not owner of this ball, its rigidbody is not active so that it doesnt hit collider? I am just trying to understand situation...
    I am syncing its velocity and angular velocity as well.So, rigidbody sould collide somehow?
     
  39. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    I misread your previous post a bit and confused myself. I meant to say "owner" where I said "server" for where you want to send the rpc from. I edited it now so it makes sense in case anyone else reads it.

    As for the explanation: The position is simply not 100% accurate on non-owners. They are intentionally in-the-past a bit so that interpolation can work (you need to have two states to interpolate between, so you can't just use the latest state, and even if you could, it would be old one moment after you received it anyway). That plus latency and the fact that the send rate is generally lower than the physics tick means that on non-owners the collision just isn't happening (or happens inconsistently). The position on non-owners is only an estimation, calculated by interpolating between two real positions from the owner. This means while it is generally visually close enough, it may actually be in a position the real object was never in, or it may not quite reach a position the real object was in (because there wasn't a state sent at that exact moment from the owner). So things like collisions can be missed on the non owner, but that just means you need to deal with those things from the owner's side by, for example, sending an rpc when the collision happens to make sure the sound gets triggered for everyone.

    Also, just a random thought, I have not tried this myself, but you could try calling the forceStateSendNextFixedUpdate() method on the owner when the collision is detected. This will cause a state to be sent ASAP, but I suspect it will already be too late at that point. Worth a try though.
     
    Last edited: Sep 24, 2021
    Gokcan likes this.
  40. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    Thanks for reporting this issue. You could try enabling vsync if that's an option for you, I have a vague memory of that fixing a similar problem for someone. I'll have to take a deeper dive into this to find a real solution though. You may also be able to try modifying the code to use LateUpdate instead of FixedUpdate or Update but I'd be surprised if that actually helped. I'll let you know when I know more.

    Oh, almost forgot to ask, which networking system are you using? It probably doesn't matter but I'd hate to spend a bunch of time trying to replicate the issue in UNet only to find out it's some Mirror specific issue or something :)
     
    Last edited: Sep 24, 2021
    13E12K likes this.
  41. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    The UNet version of Smooth Sync is dependent on NetworkMessages and RPC's so to be able to use it with your own code you would need some similar features. The more similar the easier it will be to convert the Smooth Sync code to use your custom solution. You could probably get away with not supporting RPC's without losing too much functionality (mostly just teleporting), but you really need something very similar to NetworkMessages if you want to avoid a complicated reworking of Smooth Sync.
     
  42. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    sorry didnt read the whole thread,
    but so if 2 players grab same rigidbody object, whats the default that happens?

    and would it be easy to customize that? - for example:
    - let only the first player use that grabbed object
    - or make single big object draggable by 2 or more players, imagine like a big log being carried?
    - or 2 players can pull object, but kind of both are "stuck" pulling it, neither has full control.. (or that it drops from both of them)
     
  43. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    The behaviour is driven by ownership, so you could switch owner whenever a player grabs an object and then that player would be able to control it, and you could not revoke ownership until the first player to grab it releases it. If a non-owner tries to move the object it will be "fighting" with Smooth Sync and you could get weird behaviour so generally you would just not allow that. That covers the first scenario. For your second and third scenario you'd be better off with a full server-authoritative solution where the player objects and the big draggable object are all owned by the server. Smooth Sync does support this with the Transform Source option, but it doesn't come with anything for client-side prediction, which you generally want for server-authoritative setups, so you'd have to write that bit yourself.
     
    mgear likes this.
  44. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    I don't seem to be able to replicate this issue in the example scene at least. Are you still experiencing these issues on the latest version? Can you give me any more details about your setup that might help me figure out what's triggering the errors? I can probably get rid of the errors by adding a line to normalize the rotation quaternion but it's weird that it's off to begin with. Do you notice the rotation being off when receiving these errors or does it otherwise appear to be working correctly?
     
  45. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    I just got these fixes in, sorry it took so long, but the teleport fix and the IsSpawned fix will be in the next release.
     
    CosmicStud likes this.
  46. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    Looks like this is a bug in Smooth Sync. Should be pretty straight-forward to fix though, I'll try and get it in the next release. Thanks for reporting it.
     
  47. 13E12K

    13E12K

    Joined:
    May 4, 2014
    Posts:
    20
    Thank you Zebadiah, I am using Mirror with SmoothSync. I think I have found out the solution. It worked smooth again after setting the "When to update the transform" to fixedUpdate.

    I was using ParrelSync for testing with 2 Unity instances on same PC to simulate host and client. When switching windows to client instance, somehow the FPS of the minimized window of host instance drops drastically to 10-15 FPS. This was actually the very reason for jitter. This was not the case before, so I am not sure whether SmoothSync or ParrelSync is causing the issue.

    Relating to similar FPS performance, do you think SmoothSync might cause some FPS drops both on server and client as stated in the below video? (TimeStamp: 58th second)

     
  48. Steamc0re

    Steamc0re

    Joined:
    Nov 24, 2014
    Posts:
    144
    Removed PUN and SS and reimporting both has cleared the error, I am doing very weird stuff on a spherical planet with spherical gravity, and have a lot of the variables unchecked to send, not sure if that gives you a hint as to what it could have been before.
     
  49. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    There seems to be an issue with the teleporting.
    I'm using MLAPI.
    SmoothSync version 3.36

    I followed the same code from the example `SmoothSyncMLAPIExamplePlayerController.cs`
    I was getting a lot of NullReferenceExceptions when teleporting a client, the host seemed to be teleporting fine. I added a null check in the `addTeleportState()` method which skipped all null states in the for-loop (image below). It has helped fix my issue and seemed to be working fine now but it's a bit of a red flag and may need to be looked into :)

    Thanks.

    upload_2021-10-2_10-47-10.png
     
  50. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    You're awesome!