Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

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

  1. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,560
    how do I get rid of the mirror compile errors? just install mirror?
     
  2. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @radiantboy
    If you will be using Mirror, yes install the latest version of Mirror from the Asset Store.
    If you will not be using Mirror, you do not need to extract the Mirror files. You should only extract for the networking system you will be using.

    Let me know if you still have issues after that. Cheers.
     
    radiantboy likes this.
  3. DesarrolloNinus

    DesarrolloNinus

    Joined:
    Jul 26, 2018
    Posts:
    1
    hey i'm using mirror but i got many errors the firs one was change NetworkIdentity to
    NetworkServer on the file SmothSyncMirror.cs but after that im having more issues \SmoothSyncMirror.cs(626,23): error CS0723: Cannot declare a variable of static type 'NetworkServer' do you have any update of the files ? or i just delete whic files?
     
  4. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @DesarrolloNinus
    Do you have the latest versions of Mirror from the Asset Store and the latest version of Smooth Sync from the Asset Store?

    If not, get the latest versions and try again.
    If so, try the following:
    • Delete all of Smooth Sync from your project.
    • Reimport Smooth Sync and only import the Common folder and the SmoothSyncMirror.unitypackage.
    • Unpackage the SmoothSyncMirror.unitypackage
    Let me know if that doesn't help.
     
  5. ajackster

    ajackster

    Joined:
    Feb 11, 2018
    Posts:
    1
    I am running into an issue w/ SmoothSyncNetcode where players other than the owner become "invisible" if I set Sync Scale to None (seemed to randomly happen if I had it != None but was random.) I noticed that objects that went "invisible" were actually just having their scale set to Vector3.zero.

    I've tracked down this code starting on line 2018 in SmoothSyncNetcode.cs

    Code (CSharp):
    1. if (!hasControl && !NetworkManager.IsServer)
    2. {
    3.         setScale(Vector3.zero);
    4. }
    Commenting this code out seems to resolve my issue. What is the purpose of setting the scale to 0 like this? Am I misunderstanding something or is this a bug? I would expect turning Sync Scale to None to not touch the scale value of the object at all.

    I am using Unity Netcode for GameObjects and am using SmoothSync v3.40

    Thank you!
     
    stardust_enterprise01 likes this.
  6. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @ajackster
    Definitely a bug. Thank you for letting us know. It looks like those lines were added under "Fix for sometimes not initially syncing if they are at rest." so you may get some issues related to that with that commented out. I would think a Vector3.one instead of a Vector3.zero would at least stop things going invisible but I'm not sure. This fix was added by the other guy I code with and he's out for the holidays. I'll respond when he returns in the new year or maybe I'll dig into it myself and get back to you a bit sooner. Cheers.
     
    ajackster likes this.
  7. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @ajackster
    The reason was that Netcode doesn't spawn at the updated scale by default (without Smooth Sync) so that was our attempt to not have the scale be wrong upon spawning. Then Smooth Sync would get the updated correct scale and set it.
    If you only set scale to 1, then you can probably leave that as 1 and be good to go.
    Alternatively, you can just get rid of that section if not syncing scale at all (or add a conditional to not run it). We'll have to look into an official fix for the next release. Thanks for letting us know!
    Also, please let us know if you still get "invisible" issues with it set to 1 and I can maybe get you an official fix sooner.
     
  8. dadamsj1

    dadamsj1

    Joined:
    Jul 25, 2017
    Posts:
    42
    Hi @Fuestrine

    I recently upgraded to Smooth Sync PUN2 v3.22 to v3.4. I immediately noticed a significant amount of jittering. When I reverted the commit and return to v3.22 again, the issue disappeared. Any idea what would cause this?

    Photon SendRate = 20 ms
    Sample object settings:
    When to Update Transform - Update
    Interpolation Back Time 0.06
    Time Correction 0.1
    Position Easing 0.318
    Rotation Easing 0.318
    Scale Easing 0.85
    Snap Time Threshold 3

    Note: I did not change any settings on my smoothSync objects or the send rate for Photon (commit is literally just SmoothSyncEditorPUN2.cs, SmoothSyncPUN2.cs, and StatePUN2.cs). I have the .patch files if you'd like me to send them. PUN2 is latest version as well.
     
  9. RTTTTT

    RTTTTT

    Joined:
    Apr 20, 2017
    Posts:
    1
    Hi @Fuestrine

    I'm using SmoothSyncMirror.

    Once my player object moves the scene, the client's transform is not reflected in the server. Between clients, the transform changes are well applied and are not reflected only on the server.

    In a Multiple Additive Scenes environment, Is there anything I have to do specifically when OnClientChangeScene is called?

    https://mirror-networking.gitbook.io/docs/examples/multiple-additive-scenes
     
  10. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @dadamsj1
    That's a rough one as v3.22 was almost 4 years ago around August 2019. A lot has changed since then.
    Try setting the Smooth Sync settings on your game objects to default to see if that clears it up.
    If that doesn't clear it up, do you get this behavior in the example scene for PUN2 in the Smooth Sync plugin?
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @Seugnjun
    Are you only talking about Mirror's "Multiple Additive Scenes"?
    My best initial thought is try calling the code in SmoothSync.OnEnable() or maybe even SmoothSync.teleportOwnedObjectFromOwner() for a separate reset test.
    If this is an ownership change, try setting the "Smooth Authority Changes" option in Smooth Sync.

    I'm not too familiar with Mirror's "Multiple Additive Scenes" unfortunately. If the above doesn't help, let me know and I'll have to see if I can dig deeper. Thank you.
     
  12. Davey111111

    Davey111111

    Joined:
    Dec 30, 2020
    Posts:
    2
    Super excited to try this out but I'm having an issue with the asset.
    Using Netcode for GameObjects 1.2.0
    Unity Transport 2.0.0

    I understand these are beta releases that I'm using so I understand if things aren't compatible at the moment.
    My characters movement is not being synced and the console is throwing the warning: "Could not find target for network StateNetcode message."

    Smooth.StateNetcode:Deserialize (Unity.Netcode.FastBufferReader) (at Assets/Smooth Sync/Netcode for GameObjects/Smooth Sync Assets/StateNetCode.cs:401)

    Edit: Nevermind! Problem solved :) Just had to set the Transform Source to "Server" in the Miscellaneous options because my game is server authoritative.
     
    Last edited: Jan 18, 2023
  13. AsifNaeem

    AsifNaeem

    Joined:
    Apr 12, 2016
    Posts:
    21
    I tried it with removing photon pun2 package. Re-importing latest available version. Also tried with removing & re-importing Smooth Sync. But error still resist.
    In empty package it is working fine but with my project it is showing error.
    I am using Unity 2021.3.12
    Any suggestion to resolve this issue?
     
  14. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @AsifNaeem
    "In empty package it is working fine"
    Is it working fine in the PUN2 example scene provided by Smooth Sync?
    I just tried using the latest PUN2 available from the Asset Store and the latest Smooth Sync from the Asset Store and got no issues in Unity 2021.3.5f1.

    If the PUN2 example scene provided by Smooth Sync is working fine, you'll have to see how your setup is different from this scene.
    Try redownloading the latest versions as well before you import maybe.
     
    Last edited: Jan 26, 2023
  15. VRGroupRWTH

    VRGroupRWTH

    Joined:
    Oct 23, 2021
    Posts:
    10
    We're having invisibility issues with the latest netcode for gameobjects (1.2.0) as well. Afaik they actually sync scale initially now, so when somebody joins non-scene objects have a scale of 0 until they get move once.
     
  16. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @VRGroupRWTH
    Thank you for letting us know. We will have to revisit our Unity Netcode initial settings on the next release. For now, commenting out the line should resolve it for you but let me know if it does not.
     
  17. DimVos

    DimVos

    Joined:
    Apr 15, 2022
    Posts:
    8
    Hello, I love the product, works like magic. ;)

    However, I could use your help with something about it to make it flawless for me.

    I am using this with the new Unity input system in a 2D game to flip the sprite of my character.
    Code (CSharp):
    1. if (context.ReadValue<Vector2>().x > 0)
    2.         {
    3.             this.player.transform.localScale = new Vector3(-1, 1, 0);
    4.         }
    However, no matter what I try, the sprite either never flips instantly or flips instantly almost every time.
    I am using a fairly new version of both Unity & PUN2.
    Things I have tried:
    - Updating to the latest Smooth Sync version;
    - Trying to flip it using velocity;
    - Trying to flip the sprite renderer, RB;
    - Moving the script from Update to public void MovePlayer(InputAction.CallbackContext context);
    - Changing ScaleEasingSpeed, SnapThreshold, SendThreshold (This brings me closer to my goal but I never figured out the combination to give me the perfect result).

    Can you please help me figure out the cleanest solution? Thank you for reading :D
     
    Last edited: Feb 16, 2023
  18. FPSG

    FPSG

    Joined:
    Jan 8, 2014
    Posts:
    23
    Are there plans to add support for Dark Rift 2 networking?
     
  19. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @DimVos
    Try the following:
    It looks like setting SnapScaleThreshold to .0001 or similar small number would give you the results you are expecting.
    Raising the ScaleEasingSpeed to 1 probably won't help but try that anyway if the SnapScaleThreshold to .0001 doesn't fix it.

    Let me know if that doesn't make it flip instantly over the network and I'll have to get in and test it out myself.
     
    DimVos likes this.
  20. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @FPSG
    Sorry but there are no current or future plans to support Dark Rift 2 networking.
     
    DimVos likes this.
  21. CYCLE-6

    CYCLE-6

    Joined:
    Jul 26, 2017
    Posts:
    7
    It does work for FishNet Network smoothly. But if the object recycled from FishNet Object Pool once. It doesn't sync anymore.
    You may replicate the issue in the demo. Change their "Example Player" to pooled object; Set up a server; connect a client to the server; everything works.
    Disconnect the client; Shutdown client side app. Then reopen client app and reconnect again. client doesn't sync anymore.

    Please advice...
     
    Last edited: Mar 19, 2023
  22. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @CYCLE-6
    Turn on the Smooth Sync setting under the Miscellaneous section called "Smooth Authority Changes". That should fix it up for you. Let me know if that doesn't work out for you.
     
  23. Gushmeister

    Gushmeister

    Joined:
    Apr 30, 2018
    Posts:
    43
    Hey, bought your asset for PUN2 smoothing, and it works great, it looks really smooth and position/rotation sync seems to be very good. Only problem I have now: Animations are not syncing anymore. I'm using photon animation view. What am I doing wrong? Is there a workaround for that?
     
  24. Gushmeister

    Gushmeister

    Joined:
    Apr 30, 2018
    Posts:
    43
    Okay, so actually it's not that animations don't get synced at all, it's just about the velocity. And that's very important, since I check from the enemie's rigid body, if the enemy is moving. Only the moving-variable (which actually is calculated by the rigidbodie's velocity) doesn't work. That variable isn't synced through photon animation view, I change the variable on enemies with this code-snippet.

    I am having a Photon Transform View and Rigidbody2D View. Does it make sense to sync position on the Transform view, when I'm syncing velocity of the rb already? It just seems like velocity is not synced, don't really know why. All other animations work, so it's not that the photon animation view doesn't work. I'm using PUN2

    Code (CSharp):
    1.  
    2. if (rb.velocity != Vector2.zero)
    3. {
    4.       if(!photonView.IsMine && playerAnimator.GetBool("isShooting") == false)
    5.       {
    6.           playerAnimator.SetBool("isRunning", true);
    7.           Feet.SetActive(true);
    8.       }
    9.       if (!photonView.IsMine && playerAnimator.GetBool("isShooting") == true)
    10.       {
    11.           playerAnimator.SetBool("isRunning", false);
    12.           Feet.SetActive(false);
    13.       }
    14. }
    15. else
    16. {
    17.       playerAnimator.SetBool("isRunning", false);
    18. }
    19.  
    Edit: Okay, I think I found out why it doesn't sync, because the rigid body wasn't kinematic. Why do I have to set it to kinematic? I'm using dynamic rigid bodies, since they are physics-driven, that's why my animations don't sync. Is it recommended to use kinematic rigidbodies?
     
    Last edited: Apr 25, 2023
  25. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @Gushmeister
    Hi. I responded to your email but I wanted to respond here too so others can potentially benefit as well. :)
    Don't hesitate to reach out if I missed anything or misinterpreted anything.

    (To others reading, this is my email response so the numbering and response may not be exactly responding to the above but I wanted to post it here in case it helps anyone with the same questions.)

    1.a) Smooth Sync does not sync animations. Smooth Sync only syncs
    Transforms. You can use more than one Smooth Sync to sync extra
    Transforms though if that helps.

    1.b) Smooth Sync automatically sets the velocity to 0 under most
    circumstances so that essentially only Smooth Sync is setting the
    position on non-owners because that is the way to make it the most
    smooth.
    You can probably comment out the following section in SmoothSyncPUN2
    to get your desired effect:
    if (hasRigidbody && !rb.isKinematic)
    {
    rb.velocity = Vector3.zero;
    rb.angularVelocity = Vector3.zero;
    }

    Also though, Smooth Sync will set the velocities on non-owners if you
    use the "UseVelocityDrivenSyncing" Smooth Sync variable under the
    Miscellaneous section of Smooth Sync. This won't be as accurate
    though.

    2.a) I'm not really sure to be honest. I haven't messed around with
    lowering send rates at runtime. I am always happy to offer a refund
    for any reason at any time though if Smooth Sync doesn't suit your
    needs in this or any other way.
    2b) I'm not familiar with Transform-View sync. If that is a PUN2
    thing, then you would not need it if using Smooth Sync I would think.
    2c) Sorry but I'm really not the best with Photon these days. I
    support a lot of networking systems, but I don't dig too deep into
    each one.
    I would recommend getting rid of all transform setting Photon
    components as only Smooth Sync should really be affecting the
    positions of your objects for optimum smoothness.

    Hopefully I answered all the questions.
    Please don't hesitate to reach out again if I missed anything or
    interpreted anything incorrectly. :)

    Cheers,
    Brad
     
    Meltdown likes this.
  26. Gushmeister

    Gushmeister

    Joined:
    Apr 30, 2018
    Posts:
    43
    Hey, don't worry, I got all those things running already :)

    What? Refunds? No way :) I love how fluid my Networking now is with the help of your asset. I've got all things running by adjusting a bit, I love it so far, thanks for making such a great asset! Also I like the compression-functions, this now really saves me a lot of traffic.

    Many greetings to you!
     
    Meltdown likes this.
  27. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,763
    @Fuestrine I'm having an issue in my racing with my truck landing on the track.

    Im using Mirror and have a server authoritative setup, although I have some parts of the vehicle physics running on the server, and other parts on the client for a good blend of client responsiveness and server authority.

    Both server and client have the concept of the physics suspension/wheels.

    Most of the time it works fine, but sometimes on the client when my truck's wheels land, they don't quite touch the surface, thus not registering a local client landing, so SoundFX don't play, and the truck wheels appear to float slightly above the track surface.

    Over the course of the next 2-3 seconds the client wheels seem to get closer and closer to the track, then eventually the client-side 'landing' is registered and it plays the landing sound effect.

    These are my current settings, I'm wondering if you have any advice?
    PS : I can't change to FixedUpdate, if I do, I get a lot of strange wobbling/glitching.

    upload_2023-5-22_11-4-0.png
     
  28. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    575
    @Meltdown
    Raising the Smooth Sync position, rotation, and scale easing speeds may help, but yours are already pretty high.
    You can try raising the Time Correction Speed as a test, but this will get jittery pretty quickly.
    The rest of the settings wouldn't affect that I would think.

    The issue may be that hard objects don't really collide on other systems unless using SmoothSync.UseVelocityDrivenSyncing (but it's less accurate so keep that in mind). There's no guarantee that the exact frame of collision happens on the other system and I think the last time I went down this road it wasn't colliding when I was sending and setting it specifically. SmoothSync.forceStateSendNextFixedUpdate() can be used to send specific collision positions though if you can think of anything.
    The real answer is probably Smooth Sync sending some kind of collision event trigger over along with the state and then call some code on the other side. Unfortunately I am not looking to add that feature at this time.

    Maybe a small but larger trigger circle around the tires that makes the sound occur on clients is a workaround?
     
    Meltdown likes this.