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:
    828
    Yes this is fine.
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    828
    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:
    828
    @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:
    828
    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:
    66
    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:
    12
    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:
    31
    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:
    828
    @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:
    828
    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:
    828
    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:
    64
    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.
     
unityunity