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
    @logixworx I'm don't see those errors when importing the latest Mirror and SmoothSync in to a fresh project and extracting the SmoothSyncMirror package. If you are updating SmoothSync in an existing project you should delete the "Smooth Sync/Mirror" folder and re-import the SmoothSyncMirror package after updating.

    It seems like the error is that it can't find SyncMode, but it appears to be there:
    upload_2019-6-1_2-51-54.png

    Is that file missing for you?
     
    SpindizzyGames likes this.
  2. jacobclayman

    jacobclayman

    Joined:
    Apr 12, 2018
    Posts:
    3
    I'm only syncing two objects at a time (both players). Here's footage of the delay, with settings on the side.



    This issue shows up about 1 in 10 times that I run the project. You can see events like collisions, player facing (left/right), and player death being registered immediately on both client/host, but the motion (smooth sync) is experiencing delay.

    Send rate and serialization rate are default I believe (30 and 10?).

    I'll try turning interp time to .1s and see if the issue continues to surface.

    EDIT: Could this be related to the type of pause/recompile that happens say, when you click in and out of the editor, or drag the game window around? If this causes the timestamp of the client/host to be momentarily paused or offset, would that cause a "delay"?
     
    Last edited: Jun 1, 2019
  3. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @jacobclayman
    Yeah, if the time pauses for a bit I could see that causing this issue. Increasing TimeCorrectionSpeed (increase until jittery, maybe like .5 at the most, but try at like >10.0 just to test to see if it solves the issue) or adding a low SnapTimeThreshold (~.1 or maybe even lower) would help this. SnapTimeThreshold will snap instantly if time is off by that amount while TimeCorrectionSpeed will slowly correct each real time second by that amount of seconds.
     
  4. jacobclayman

    jacobclayman

    Joined:
    Apr 12, 2018
    Posts:
    3
    Ahh, gotcha. I'll try those settings and see if the issue rears again, thanks!!

    EDIT/UPDATE: Aha, yep. Catching the issue when it happened and tweaking the snap time fixed it. Thanks :)
     
    Last edited: Jun 2, 2019
  5. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
  6. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Hello, I just purchased this asset and tried to use this asset. I have parent object with photonView and child object. I want to sync only single object but I learnt I need to add two script onto parent and set child for one of them. I did that but I got error. Is there any active tutorial for that ? Do I need to add two script into PhotonView Observe?
    Thank You.
     
  7. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hello, just bought the asset hoping it would solve an issue with rigidbody networking not being the same on server and clients using Mirror. Basically the client sends input information to the server rather than move the client's own player object, and then the server moves the player gameobjects and then sends out new positions to all clients including the player that initiated the move. However when the game objects collide (they are just cube placeholders for now) the rotations and positions can get disjointed / out of sync and I thought this asset would help with this.

    Was I expecting too much? Cheers.
     
  8. SpindizzyGames

    SpindizzyGames

    Joined:
    Jun 29, 2017
    Posts:
    108
  9. SpindizzyGames

    SpindizzyGames

    Joined:
    Jun 29, 2017
    Posts:
    108
    Has SmoothSync/Mirror been tested with the Ignorance udp transport for Mirror? I can't get it to connect even with my firewalls turned off. Any ideas?
     
  10. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    Thanks for your reply.
    I have tried everything I can think of including using default values.
    But I get the same result.
    Sometimes the latency is over a second and I am testing both client and server on the same machine.

    Any thoughts on the next steps to try to resolve this?

    Currently using Unity 2018.3.14f1 and UNET.
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Ceylan12
    I'm away from my computer for a bit to know for sure, but take a look at the Photon example scene. It shows an example for an object with a parent and a child. Let me know if you have questions after seeing that scene and how the object should be hooked up.
     
    Last edited: Jun 3, 2019
  12. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @tapticc
    No, it should work in your scenario. The objects shouldn't become out of sync.

    My only guess is that maybe something isn't set up correctly. Use the default settings if you aren't. Also take a look at the Smooth Sync Mirror example scene in case you have some weird setup, there's an example Smooth Sync object in that folder too.

    To recreate what I think is your scenario, you can just add another player object to the example scene and then there's two server owned objects that can collide and it never becomes out of sync for me.

    Let me know if taking a look at the example scene doesn't help alleviate your issue.
     
  13. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    Hmm, I'm not too sure. I don't see this issue in the example scene. Does this happen in the example scene for you?

    Is this happening every time for you? I had someone recently that maybe had a similar issue. Try setting the SnapTimeThreshold to .1 for me and see if it still happens. Theirs was caused from the game being frozen/paused.

    The next step after that is probably sending me your project in a PM or by email and I can take a look at your specific scenario.
     
  14. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @logixworx
    That scene no longer exists, it was just for videoing purposes. You can take the regular example scene and add a bunch of the example player objects though and get basically the same thing.

    If your game isn't connecting at all, Smooth Sync shouldn't be getting in the way of that. Smooth Sync only does things after you are connected. If your scene connects when you aren't using Smooth Sync and doesn't connect when you are using Smooth Sync, let me know and I'll take a look at it though.
     
    Last edited: Jun 3, 2019
  15. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Thank You, proglem has been solved but I have another proglem :) Sync across network in scene view looks like good but when I follow synced car with another car It looks like laggy. All of the scripts work with FixedUpdate. How can i solve this proglem ?
    Thank You.






     
    Last edited: Jun 3, 2019
  16. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Ceylan12
    It looks like you are moving the car on both sides of the network. You will want only Smooth Sync to handle the movement on non-owners. Try adding a

    if (hasAuthority)
    {
    // Your movement code
    }

    Let me know if that doesn't help.
     
  17. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Thank you for answer, I'm closing movement Script if it isnt local player so proglem can't be that.
     
  18. MyNameJeff22

    MyNameJeff22

    Joined:
    Nov 27, 2016
    Posts:
    26
    anyone have a rough estimate of how many objects this can handle?
    I understand it depends alot on server bandwidth and resources as well as client hardware and bandwidth but is there a graph of what to expect?
     
  19. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Ceylan12
    Try moving the Camera in Update(). I'd also probably set WhenToUpdate to Update().

    Another thing could be to have the camera be a child of the object it is following.

    If those don't work, there's also UseVelocityDrivenSyncing under the miscellaneous tab on Smooth Sync if your object is a rigidbody and it'll smooth some things out.

    Let me know if none of that helps.
     
  20. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MyNameJeff22
    How many objects it can handle depends on too many factors. You can turn the send rate way down and save bandwidth, there's also things to save on performance. Maybe someone else has a good idea of what they've done but I don't really have any estimates myself. The trailer shows some things, those are all two players though.
     
  21. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    When I moved all of that code to Update lag started to be in local and Multiplayer. Proglem didnt solved.

    I didnt understand second solution. My camera isn't child of moving car. Does it need to be child or not?

    I tried VelocityDriveSyncing and it didnt Sync Car and I have a lot of collision in my game. I think this selection not for my game.

    Communication is too late for our clocks do not match. Can we somehow handle the question at one time?
    Thank You.
     
  22. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Ceylan12
    Yes, I would try making the locally owned camera a child of the unowned moving car if that's where your jumpiness is at. The camera being a child of the car will help them be in sync with each other.

    Following an unowned networked object with a locally controlled object is a bit weird since the movement isn't going to be in perfect sync. If you play Fortnite, you'll notice the same issue when running behind a player. It becomes much more noticeable dropping from the air in Fortnite too.

    Can you rephrase this? I'm not sure what you are saying.
     
    Last edited: Jun 6, 2019
  23. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Can you tell me what GMT time you're active? Can I ask a question and get a quick reply?
    Also @MustangLM's proglem in 10th Page same with my proglem. Did his problem solved?
     
    Last edited: Jun 6, 2019
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    You can try us on the discord for more real time communication. https://discord.gg/6VpgNQg

    After 10PM GMT is probably best, but I'm there at all sorts of random times.
     
    Last edited: Jun 6, 2019
  25. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    Setting the SnapTimeThreshold to 0.1 seems to have fixed the problem.
    I will let you know if I run into anymore issues.
    Thanks for your help.
     
  26. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Ceylan12
    If it's the same as Mustang's problem, then the fix was to use "UseVelocityDrivenSyncing". You'll need to have your cars be able to be affected by velocity though and it's going to be less accurate. If it's just the camera following issue, putting the camera as a child should help.

    I'm only active for a very short time every day that's random for the next couple weeks, you can try communicating with thegreatzebadiah on discord though for a little back and forth immediate conversation.
     
    Last edited: Jun 7, 2019
  27. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    Glad to hear! If you notice jitter from that variable being low, maybe raise it to like .2 or something. Definitely let me know if you run into any issues or have questions.
     
  28. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Hello, I just bought Smooth Sync,

    Seems to work great, without it my game was totally useless with the crazy lag.

    I just have one problem now, im using the free unity car from asset store, i attach the smooth sync PUN to it for two players.

    Each player can take turns driving the car, the car drives smooth and everything, but for the player thats not driving the car the car wheels dont spin, it only spins for the driver, for the player just observing, the car just moves and the wheels dont turn like normal, even though im sending the turn and accelleration commands via RPC to the other player.

    Seems the rigid body is turned off in the car without the driver. The wheel system uses the rigid body to operate the wheels spinning, so only the car body moves now, but the wheels dont turn except for the driver.

    Any idea how to fix that?

    Thanks
     
    Last edited: Jun 20, 2019
  29. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @nsmith1024
    Smooth Sync shouldn't be turning off the rigidbody I don't think. I do set the rigidbody velocity to zero though on non-owners so that it doesn't mess with the position that Smooth Sync is trying to set.

    I don't know how the free car asset works but:
    The easiest way to sync them is probably to add a Smooth Sync component on the wheels (or the axle if that's how it works).
    One other way could be to send an RPC to tell the wheels to spin and turn.
    The way to save the most bandwidth is probably to figure out the velocity of the car locally (not using the rigidbody, just using position) and spin the wheels based on that.

    One maybe way that I probably don't recommend, is commenting out where I set the rigibody velocity to zero. Look for "// Reset to 0 so that velocity doesn't affect movement since we set position every frame." in the code.

    Let me know if none of that helps, or if I misunderstood, or if you have any questions.
     
  30. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Hello,

    I recently bought your smooth sync. Im using it with a simple multi-player ICE HOCKEY game, where each players character has rigid body + smooth sync PUN attached to sync their position.

    I also attach a rigid body + Smooth Sync PUN to the hockey puck.

    Im syncing only the position and velocity for all.

    Players run around the ice court, hockey puck sliding around, player collide with the puck sending it off somewhere.

    However, when a player hits the puck, there is a delay between the time the player hit the puck and when the puck actually starts moving, so it looks very strange because after the player runs into and hits the puck, they can actually run way past it before the puck reacts to the hit and then suddenly fly's off overtaking the player.

    I tried various settings on the smooth sync PUN inspector, but no luck so far.

    I thought this is a simple situation, but i cant get it to work.

    I dont know whats really going on, because since the puck can be hit by anyone there is no owner.

    Also this delay seems only apparent to the players who are NOT the master and doing the hitting, the remote players dont know exactly when the hit occurred, so they dont see a big delay between the hit and the puck moving. So maybe the smooth function is sending the movement to the master and back before the move happens, so maybe the movement can be started locally so the player doing the hitting can see the instant reaction of the puck??

    Anybody knows how to fix? Is there an "allow control locally" setting somewhere in the smooth sync system?

    Thanks
     
    Last edited: Jun 30, 2019
  31. unknown17771

    unknown17771

    Joined:
    Nov 12, 2016
    Posts:
    19
    I want to buy this asset, but can i use this for Google Play Game Service Multiplayer?
     
  32. romain1994

    romain1994

    Joined:
    Oct 23, 2018
    Posts:
    26
    Hello,

    Firstly, I would like to thank you for this awesome asset that has made our life so much easier, really.
    However, we are having some difficulties and would love your assistance.

    We are developping a 3D multiplayer action game that involves a lot of shooting between networked players.
    In order to handle the networking stuff, we are using the Unity engine along with Photon PUN.

    Each networked character has a SmoothSyncPun2 object as an Observed Component.
    "Regular" movements, as in just continuously moving around, is synced beautifully.
    But, as a main feature of our game we would like to implement a knockback that occurs when a character gets hit with a projectile.

    The projectile are being initiated with an RPC and are being instatiated locally on every screen.
    The hit detection is done with a short (2 distance units ahead max) sphereCast, since the projectile is relatively large and slow.
    When the projectile hits the player, we addForce as ForceMode.Impulse.

    Now, lets say A shoots B.
    On screen B the knockback looks perfectly synced, since the projectile is locally instantiated (by the networked RPC).
    However on screen A, player B is hit with the projectile and then, after a small but very noticeable delay, is "synced" to his position after the knockback.

    We were wondering if there is an optimal set of parameters for SmoothSync to deal with this sudden change in position.

    These are the parameters we are currently using:

    When to Update Transform: Update
    Interpolation Back Time: 0.02
    Time Correction Speed: 3.98
    Position Easing Speed: 0.908
    Rotation Easing Speed: 1
    Scale Easing Speed: 1
    ...
    Extrapolation Mode: Limited
    Use Extrapolation Time Limit: true
    Extrapolation Time Limit 2
    Use Extrapolation Distance Limit: false
    Extrapolation Distance Limit: 10
    ...
    Thresholds all 0
    except for Snap Time Threshold: 3
    ...
    No compression (yet)
    ...
    no Misc options

    thank you in advance
     
  33. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @mybreeze
    Yes, Smooth Sync will work on android devices. It has nothing to do with Google Play Game Service Multiplayer and will work fine with it. Smooth Sync just sends information via Unity and syncs the transforms of objects. Let me know if you have any questions.
     
    Last edited: Jul 4, 2019
  34. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @nsmith1024
    Unfortunately it's not a simple problem that can be easily solved. The position is only controlled by one system. With the puck being controlled by the owner, you won't be able to move it on other systems because it's trying to be placed in the position that it's at on the owner. You can try turning Smooth Sync off and on or you can try changing the owner when someone takes possession, both are trade-offs though.

    Let me know if you have any questions or if I didn't answer anything.
     
    Last edited: Jul 4, 2019
  35. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @romain1994
    There's not much that can be done about that automatically unfortunately. If your players are owned locally and your projectile is owned on another system, they are going to be off by the amount of ping at least (plus some number of frames because of how Unity works). A lot of networking is hiding this fact.

    You can try turning Smooth Sync off on the player that isn't owned that is hit on the non-owners screen and then pushing them back. Then turning Smooth Sync back on. That might have some jump though when you turn Smooth Sync back on.

    You can also not register the projectile hitting unless the owner of the player says they are hit, then it won't look weird if it explodes before they get knocked back.

    Let me know if you have any questions or if I didn't answer anything.
     
    Last edited: Jul 4, 2019
  36. diedetap

    diedetap

    Joined:
    May 18, 2018
    Posts:
    2
    Hi there,

    I came across your asset and wondered if its able to do what i'm looking for:
    I'm currently working on a local multiplayer VR game in which there are 4 players in VR. Players will be able to see each other as avatars within the playspace. Is there a way to sync the VR headset and controller positions of each player to the other players but diverting these to their corresponding avatar gameobjects (instead of the actual headset/controllers of the other players)?

    Thanks!
     
  37. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @diedetap If you're game is truly local multiplayer (everyone playing on one computer) and not networked at all then SmoothSync is almost certainly not the asset you're looking for. If your game is networked though, then SmoothSync should be able to do what you need. I think the way I would approach it though is to have have the avatar exist everywhere, including on the owner, where it is controlled by the headset and controller positions. You would then sync the avatar like any other object using SmoothSync. All you would need to do is not actually render the avatar on the owner (disable all mesh / sprite renderers) and it should be golden.
     
  38. diedetap

    diedetap

    Joined:
    May 18, 2018
    Posts:
    2
    Thanks for the quick reply. Local multiplayer wasn't really the right description, it is networked but everybody is physically in the same room. Thanks for the explanation, that seems pretty straightforward. Looking forward to trying it out!
     
  39. Foestar

    Foestar

    Joined:
    Aug 12, 2013
    Posts:
    350
    Edited: Removed my question. I was being an idiot and failed to finish part of the setup. It's always the dumb things that get me or stump me for a bit. SmoothSync is working great!
     
    Last edited: Aug 13, 2019
    thegreatzebadiah likes this.
  40. cookiester34

    cookiester34

    Joined:
    Jan 17, 2019
    Posts:
    2
    Hey, so i just bought smooth sync, at first it worked amazingly, then it just stopped working for all AI in my game for the client, the players all still work, but AI only moves on host if I use the UNet network transform it works again any clue why this is happening, I'm using mirror aswell.
     
  41. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @cookiester34
    It sounds like maybe your AI is trying to set the position on your non-owners (in your case your clients?). Confirm that only Smooth Sync is setting position on non-owners. If that's not it, let me know.
     
  42. caiomcoliveira

    caiomcoliveira

    Joined:
    Aug 4, 2019
    Posts:
    1
    Hello, I am making a 2.5d game (using 2d rigid bodies ) that relies on some rigidbody collisions ( players againist players, and player againist ball)
    However, the collision only seems to be working smothly on the Master Client ( I am using PUN2) . The other players collides with the ball as if it was unmovable.

    Should smooth sync solve this problem or am I doing something wrong?

    I attached the photon view, and attached the smooth sync controller as an observable, both on the ball and the players.
     
  43. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @caiomcoliveira
    Hey, I think I replied to you on Discord already but I wanted to reply here too so others could see also that I'm not ignoring you. :)

    Smooth Sync won't solve physics collision simulation when two different systems control the position. You'd want all positions determined by one system. A game with collisions like Rocket League would be server authoritative (cars and ball positions controlled by the server). Keep in mind that Rocket League also has good player prediction so that it seems like your car is moving instantly on your screen even though the server is actually determining the position.

    One way to keep them as separate owners would be to send an RPC and rigidbody.AddForce() or change the rigidbody velocity.

    Let me know if you have any questions.
     
  44. cookiester34

    cookiester34

    Joined:
    Jan 17, 2019
    Posts:
    2
    Hey so I switched to PUN2 and solved the issue thanks for replying anyway.
     
  45. sonderistic

    sonderistic

    Joined:
    Jan 4, 2017
    Posts:
    7
    @Fuestrine Hi, we currently have objects that have smooth sync attached to them and exist in the scene from the start, i.e., not spawned in. These objects for some reason move positions immediately after the game start. Any ideas why this could be happening?
     
  46. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @sonderistic
    I don't think I understand your question. Can you explain in more detail what is happening?
    What is "game start"? Where are the objects moving to? The objects are moving to completely different locations than where the objects are?
     
  47. Doughtinator

    Doughtinator

    Joined:
    Aug 8, 2019
    Posts:
    10
    I’ve just bought the smooth sync asset.

    I’m wondering if there is a setting or an edit of the code that will do what I would like.

    I have objects that have local authority but are being moved by physics applied on the server via commands.

    On the client it seems that smooth sync locks the position of these objects.

    Is it possible to only have the server set the smooth sync transforms?

    I’m using mirror networking with smoothsync

    Thanks
    Chris
     
  48. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Doughtinator
    If you want the server to determine the position of your objects you will have to make the server the owner of the objects.

    Let me know if I misunderstood or if you have any other questions.
     
  49. Doughtinator

    Doughtinator

    Joined:
    Aug 8, 2019
    Posts:
    10
    Thanks for the quick reply.

    How would I make the server the owner of the object but still allow a player to move it?

    I want tight physics interaction between objects and players so I am commanding the objects to move on the server.

    The objects only respond to these commands if they have local authority.

    I was hoping it would be possible to make some adjustment in the smooth sync code where it would only update the position based on the servers transforms.

    Thanks again
    Chris
     
  50. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Doughtinator
    You can have the non-server player tell the server to move it.

    Usually this is done by having a PlayerController owned by the local systems and having the players and game objects owned by the server. You then send over your CMDs to the server on the PlayerController which tell the player objects to move.