Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    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. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    Yes this is fine.
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  3. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    @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.
     
  4. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  5. SnooksV3

    SnooksV3

    Joined:
    Dec 11, 2018
    Posts:
    10
    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?
     
  6. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    82
    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?
     
  7. Japsu

    Japsu

    Joined:
    Jan 17, 2018
    Posts:
    13
    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.
     
  8. 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.
     
  9. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    32
    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?
     
  10. SnooksV3

    SnooksV3

    Joined:
    Dec 11, 2018
    Posts:
    10
    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.
     
  11. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    @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.
  12. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  13. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  14. 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.
     
  15. 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.
     
  16. 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
  17. 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?
     
  18. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  19. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  20. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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.
     
  21. gregacuna

    gregacuna

    Joined:
    Jun 25, 2015
    Posts:
    57
    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.
     
  22. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    52
    I know how to use playmaker if you want I can help you with your problems.
     
  23. Mjhurtado1

    Mjhurtado1

    Joined:
    Mar 13, 2013
    Posts:
    3
    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?
     
  24. thegreatzebadiah

    thegreatzebadiah

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

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    835
    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?
     
  26. Mjhurtado1

    Mjhurtado1

    Joined:
    Mar 13, 2013
    Posts:
    3
    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.
     
  27. LastChaos

    LastChaos

    Joined:
    Dec 9, 2013
    Posts:
    34
    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
  28. OnlyTheCosmos

    OnlyTheCosmos

    Joined:
    Jun 13, 2017
    Posts:
    25
    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
  29. OnlyTheCosmos

    OnlyTheCosmos

    Joined:
    Jun 13, 2017
    Posts:
    25
    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!!!
     
  30. Steamc0re

    Steamc0re

    Joined:
    Nov 24, 2014
    Posts:
    131
    @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
  31. Cuttlas-U

    Cuttlas-U

    Joined:
    Apr 11, 2017
    Posts:
    24
    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
     
  32. 13E12K

    13E12K

    Joined:
    May 4, 2014
    Posts:
    15
    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
  33. gotonightmare_unity

    gotonightmare_unity

    Joined:
    Sep 14, 2020
    Posts:
    1
    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`
     
  34. thangnh111

    thangnh111

    Joined:
    Aug 4, 2020
    Posts:
    9
    Does it work with client side prediction?
     
unityunity