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

    thesupersoup

    Joined:
    Nov 27, 2017
    Posts:
    70
    Trying to self-diagnose before posting a video...

    Everything in my game, both players and AI controlled NPCs, has a SmoothSync script.
    Things were fine before updating Unity to 2018.1 and moving from my test room to the actual game environment (4000X by 4000Z). I'm not sure specifically which change triggered the issue, because I had been testing single-player in the new environment before trying multiplayer again.

    Now when anything moves, it looks fine on the Host (with the exception of the Client player), but on the Client NPCs and the Host player do this weird zig zag motion. It all still works though, remarkably; I'm able to damage entities at roughly the appropriate position, but the motion is really rough and stops/starts. I'm assuming this is because I'm not doing something correctly with regard to ownership or Server-authoritative positions, which I want.

    Should I be disabling the script on GameObjects for the Client? e.g. (if(!isServer)SmoothSyncScript.enabled = false)
     
  2. thesupersoup

    thesupersoup

    Joined:
    Nov 27, 2017
    Posts:
    70
    Ok, in the spirit of self-diagnosis, I went through and disabled the SmoothSync on Client NPCs. That seemed to clean them up.

    Now I'm just wondering how to approach the Players. I'll continue tinkering in the meantime.

    (EDIT: I can't find a good solution for the Players. Obviously, both Players require the SmoothSync enabled for every Client, of which the Host is one. Disabling SmoothSync along with my other clientside components, of course, prevents that Client from synchronizing their position as far as the others are concerned. Should I work into the script a disabling of LocalPlayerAuthority for Client PlayerObjects? Meaning, on each Player's instance, their PlayerObject is the only one with LocalClientAuthority?

    EDIT 2: Player Movement is accompanied by a massive frame dip on the viewing Client. Sub ~30fps from 60-80fps. I saw it hit ~15fps at times. Since SmoothSync defaults to updating the transform on FixedUpdate(), could that be part of the reason Clients are seeing the other Clients hop and skip around? Is this a common issue?)
     
    Last edited: May 31, 2018
  3. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @foolmoron
    Yeah, I'm definitely seeing the same problem. Sorry about the issue. I believe I already have a fix for it. It looks like I can finish it up tomorrow. Also, thanks for the simple example project, the issue was easy to replicate.

    For your hitting the edge of the walls problem, it's just a limitation of sending only so many times, it just may never be in that exact location when it sends the Transform out. I have a method called forceStateSendNextFrame() on SmoothSync.cs which you can call whenever you want to force the current location to send. An example of using it is in the example scene on SmoothSyncExamplePlayerController but all you have to do is call that method when you want to send the current Transform. You'll probably want to hook it up to a trigger on wall collides or something like that. Let me know if you have any other questions about it, otherwise, I'll see if I can finish up that fix and get it to you tomorrow.
     
    Last edited: May 31, 2018
  4. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @thesupersoup
    You'll definitely want the SmoothSync script enabled on every object that is enabled (on both clients and server). Setting WhereToUpdate to Update will indeed help it be less choppy but I don't think that's your main issue.
    I would not be messing with LocalClientAuthority. I don't imagine it'd be a problem with that.

    It sounds like you have NetworkTransform and SmoothSync on the same object and they are both trying to update the position. You don't want to have NetworkTransform on the object.

    Can you send me a screenshot of your game object and it's components that you are trying to sync across the network?

    One thing is that the highest version I show support for on the Asset Store is 2017.3.0. It's about time I updated to 2018 anyway so I'll take a look at that when I dive into SmoothSync tomorrow and see if I can see any problems.

    Let me know if you have anymore questions. Cheers.
     
  5. thesupersoup

    thesupersoup

    Joined:
    Nov 27, 2017
    Posts:
    70
    I agree that I don't think it's my main issue. For the Player I don't have half as many SyncVars as the NPCs. I reached the SyncVar limit on the AI Manager script, and there are many other SyncVars besides.

    EDIT: For clarity, of the pictured components, I only disable FirstPersonController on (!isLocalPlayer) instances, along with the Camera and AudioListener. Also, I'm running the compiled game as a second instance on the same PC, which had worked fine historically...

    I can say for certain I don't have NetworkTransform. As soon as I found SmoothSync I purged that hard. And it worked perfectly fine enabled on everything in my testing area, also in 2017.3 or .4, I can't recall exactly which I upgraded from. Both Players and NPCs were drag-and-drop smooth and functional with SmoothSync, even as I tested the limits with hordes.

    The attached screenshot includes the Player GameObject, and any SyncVars in the pictured Scripts. The second SmoothSync is for a child; the weapon in the hands of the player. Settings are identical and default for both SmoothSync scripts, except that I set Sync Velocity and Sync Angular Velocity to NONE...

    Ah, wait. After I typed that I went and checked, and the Child SmoothSync still had XYZ for both the aforementioned. While I await your response, I'll try another build with that corrected. And I'll try the testing scene again to see if it's something to do with the big environment. But as I mentioned before, the environment is only 4k x 4k Units. I don't think I'm bumping up against any floating point inaccuracies.
     

    Attached Files:

    Last edited: May 31, 2018
  6. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @thesupersoup
    Yeah, it's sounding like it's just because I don't support Unity 2018 yet. Maybe something changed but I can't imagine what would have. I'll look into that tomorrow and get back to you.
     
  7. thesupersoup

    thesupersoup

    Joined:
    Nov 27, 2017
    Posts:
    70
    Thank you, I appreciate your time. I know you're a busy guy; full disclosure, this won't become a mission critical issue for my team until about the second week of June. But if you find a solution sooner, I would be happy as a simile.
     
  8. thesupersoup

    thesupersoup

    Joined:
    Nov 27, 2017
    Posts:
    70
    In case more info helps, I did some more testing with two local instances. It seems like the problem may be that things are ever so slightly out of sync/offset from one another. I tried standing the Players directly in front and facing each other, and as I walked toward one (Client walking toward Host) it looked like I was approaching a point about ~2ft. off to one side. And the zig-zag motion I had noticed seems like the script is trying to correct for the offset, but isn't quite able to; it never perfectly matched up, and it still stutters and jumps around like there's massive packet loss.
     
  9. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    @Fuestrine Awesome looking forward to the update!

    As for this, I feel like 30 samples/sec should get the ball MUCH closer to the wall than it does now since it's only half the rate of the actual physics. Also I tried changing the send rate to 60 and send position threshold to 0 and also the forceSend() on collision and nothing changed. Is there another limit to send rate somewhere?

    Actually I'll just try after your update cuz that might be affecting it.
     
  10. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    It's because you wrote this earlier:
    and this confused me.

    One more question. If I have several Smooth Sync components with Child Object assigned, and one "parent" Smooth Sync, can I set its Send Rate to zero? Because I don't need to actually send parent transform, it's just a root component for children.
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @foolmoron
    Ah I see it fully now, you are right. Sorry about the misinformation. You're sendRate is definitely high enough that it should be better than it is showing here. The main reason seems to be because the positionLerpSpeed is low. SmoothSync doesn't just go in straight lines from point to point because it looks kind of jagged. So we lerp towards the point where it should be based on the determined time. Turn positionLerpSpeed to 1 to get instant position movement, but you'll probably want something between .9 and 1. I think I need to revisit the default values for variables and probably the comments.

    One other thing to keep in mind that definitely isn't your main problem but ties into the sendRate problem from earlier, is that the time just may never line up. If it gets sent a point in time at 1.55s but it literally has no update at the 1.55s determined time on the non-owner, then it will never try to be at that position.

    Let me know if you have any other questions. I'll message again later anyway with the results of my other fixins.
     
    Last edited: May 31, 2018
  12. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @hottabych
    Yes, you can have the parent sendRate at 0 and the children will sync fine.
     
    Last edited: May 31, 2018
  13. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    Okay this makes a lot of sense, thanks

    Also I just tried with high position lerp and it goes right to the edge yup!
     
  14. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @thesupersoup
    It works in 2018 for me so it's probably not that. Screen shot me your Smooth Sync settings?

    If your Smooth Sync settings look fine, I can always just take a look at your project if you have something you can send over. It doesn't seem like it, but I've also got a fix for another user that I'm finishing up tomorrow that might solve your issue.
     
    Last edited: Jun 1, 2018
  15. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @foolmoron
    Yep, it's way better now under those circumstances. I've got some other related stuff I want to look into now too though. I've also got unrelated things I want to put in this update.

    If you want the fix now, I can send it over. Otherwise I'll probably have the version I'll be putting up on the Asset Store in a few days. If I don't hear from you, I'll message you then.
     
    Last edited: Jun 1, 2018
  16. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
  17. thesupersoup

    thesupersoup

    Joined:
    Nov 27, 2017
    Posts:
    70
    See attached.
     

    Attached Files:

    • ss.PNG
      ss.PNG
      File size:
      42.4 KB
      Views:
      725
  18. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    How to teleport the object? I set its position on one client, but due to SmoothSync it tries to lerp to that position on other clients!
     
  19. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @hottabych
    Take a look at the example scene provided in the plugin. On SmoothSyncExamplePlayerController I have a teleport example. I would have it built in easier but Unity doesn't allow RPCs from plugins. Let me know if you have any problems.
     
    hottabych likes this.
  20. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    Here's a general question:
    If SmoothSync has everything delayed by 0.2s or whatever due to interpolationBackTime, how does that sync with the rest of the game that isn't delayed by 0.2s?
     
  21. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @foolmoron
    It'll just be off.

    For an explanation of why:

    It's why in every FPS you have people complaining that they "definitely hit that guy" but it was really only on their screen, and their screen is slightly off from the server version of the game. It's just a physical limitation of the fact that you can't send messages literally instantly across the internet.

    https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking#Entity_interpolation
    is where you can read a better and more detailed explanation by the Counter-Strike devs about interpolationBackTime and some other tricks.

    You'll basically have to make concessions as you go along. Networking is basically nothing but trade offs.
    Take for example a standard FPS. You could have someone never go "What? I definitely hit that guy" and you can have the client determine whether they hit someone or not. But it's just not literally where the object is on the other screen at this instant. So now you have the person who got hit going "What? I definitely didn't get hit by that guy". Most FPS games will have a dedicated server setup with almost full server authority so they land somewhere in the middle of that.

    Let me know if I was confusing in any of that or if you have more questions.
     
    Last edited: Jun 8, 2018
  22. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    Yeah that's what I figured.

    I guess I'm wondering if there's a way to buffer and sync RPCs and CMDs with SmoothSync's delay. So if SS interpolation is 0.2s and an RPC fired at server real time 1.0 and it reached the client at real time 1.1 (client SS time 0.9) then it would wait 0.1s until client SS time 1.0 before applying the RPC to the client. Same with SyncVars and such.
     
  23. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @foolmoron
    I think if you send over the network time with
    NetworkTransport.GetNetworkTimestamp() in your RPC
    then you can wait for the InterpolationTime in ApplyInterpolationOrExtrapolation() to pass that mark.

    I'm not 100% on that though but it should at least get you headed in the right direction. I have no clue about the SyncVars.

    If you have a high enough send rate, I would think .1 is more than enough for your interpolationBackTime though. I'm also about to push a version that handles lower send rates and higher latencies a bit better if that's your limiter for why you want interpolationBackTime to be so high.
     
  24. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    Nah I do want as low of an interp time as possible, and I am trying it now with just 0.1s. But ultimately that still allows RPCs and syncvars to apply too early. And in the case of high pings it would be too late.

    I can't dynamically change the interp times based on ping because that will mess things up right? Basically I would want each client to have its own interp time based on ping to the server so events are relatively synced up. But each network message is going to have its own individual ping anyways so it can't be too accurate.

    I really just need a way to configure all HLAPI requests to be buffered and respect the delayed time simulation of the game, which I doubt is possible cuz the API sucks. This might be why people always suggest using the LLAPI...
     
  25. Icyteck01

    Icyteck01

    Joined:
    Dec 27, 2016
    Posts:
    31
    @Fuestrine Do i have to use a network manager? or i can make my own scripts?
     
  26. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @foolmoron
    My general advice, without knowing what you need at all, is that you are probably overthinking it too much. Sometimes you just won't be in the exact spot for an RPC. Things happen oddly in multiplayer games all the time. If you play Fortnite and don't curse the networking at least a few times, then you aren't playing it right, lol.

    You might be able to mess with interpolationBackTimes but you'll most likely get a jump when you try to adjust it.

    I'll send you a copy via PM here tonight or tomorrow of the newer version that should allow lower interpolationBackTimes while being smooth and you can see if you can lower it and see how well it all lines up.
     
  27. foolmoron

    foolmoron

    Joined:
    Jun 22, 2013
    Posts:
    41
    @Fuestrine
    Yeah you're probably right. We explicitly decided that we were okay with a limited janky online mode, so I shouldn't worry too much about it... with a low interp time it should be fine. So I look forward to your update!
     
  28. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @LegalSin
    That's a good point. I just changed it and you no longer need to use Unity's Network Manager.

    It'll be about a week before it shows up on the Asset Store so if you buy a copy and you want the new version immediately, send me your invoice number in a PM and I'll get you the new version.
     
    Last edited: Jun 11, 2018
  29. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine,
    I've recently been having issues with smooth sync on firstpersoncontrollers. The issue seems to occur randomly but more for some users than others but only when the player is spawned threw code at realtime.

    Code (CSharp):
    1.     [Command (channel = 0)]
    2.     void CmdCreatePlayer (Vector3 position, bool teamBlu, string name)
    3.     {
    4.         GameObject g = (GameObject)Instantiate (actor, position, Quaternion.identity);
    5.         ClientScene.SetLocalObject (netId, g);
    6.         NetworkServer.ReplacePlayerForConnection (connectionToClient, g, playerControllerId);
    7. ().AssignClientAuthority (connectionToServer);
    8.         Actor a = g.GetComponent<Actor> ();
    9.  
    10.         a.SetTeam (teamBlu);
    11.         if (name.Length < 1) {
    12.             a.playerName = "UnnamedDude";
    13.         } else {
    14.             a.playerName = name;
    15.         }
    16.         currentSyncPlayer = a.transform;
    17.     }
    What happens is one or more players are not synchronized at all, this is massivly gamebreaking and has forced me to use the default network transform component.
    Any ideas on how to fix this?
     
    Last edited: Jun 14, 2018
  30. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @IdiotsCode
    Sorry about the issue. It's certainly weird that it's random and not consistent.

    Are the objects spawning fine on all systems? Are they jumping around on all systems or sitting still?

    It looks like you end up with the server owning all of these objects. Is this the intended result?
    Can you show me what ().AssignClientAuthority is acting on?

    I'm not sure who's supposed to own your objects but see if
    Debug.Log("hasAuthority " + hasAuthority);
    makes sense on your objects because only owners (hasAuthority == true) will control the movement of the objects.
     
  31. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine

    The objects are all spawning fine and there is clearly data being sent (When the player shoots the frozen version of him on other players screens fires their gun, and they can kill other players). And all of the players have authority as they are all able to send chat messages and move its just other people don't see them move.

    What makes it even weirder is that using the network transform works perfects (Looks super duper jittery but at least it works). The local player object is running that code and spawned by the server at the start of the game when the player selects a team there player object is spawned with the CreatePlayer function.

    The players are meant to and do have authority when this issue occurs.

    The ().AssignClientAuthority was a typo that was //'d out in the original code

    Code (CSharp):
    1.     [Command]
    2.     void CmdCreatePlayer (Vector3 position, bool teamBlu, string name)
    3.     {
    4.        
    5.         GameObject g = (GameObject)Instantiate (actor, position, Quaternion.identity);
    6.         NetworkServer.Spawn (g);
    7.         NetworkServer.ReplacePlayerForConnection (connectionToClient, g, playerControllerId);
    8.         ClientScene.SetLocalObject (netId, g);
    9.         Actor a = g.GetComponent<Actor> ();
    10.    
    11.         a.SetTeam (teamBlu);
    12.         if (name.Length < 1) {
    13.             a.playerName = "UnnamedDude";
    14.         } else {
    15.             a.playerName = name;
    16.         }
    17.         currentSyncPlayer = a.transform;
    18.     }
    It only appears to be an issue with smooth sync. (The smooth sync's used are 1 base one and 2 child object syncs)
     
  32. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @IdiotsCode
    I tested a bunch in the example scene and I didn't get any issues.

    Code (CSharp):
    1. if (Input.GetKeyDown(KeyCode.I))
    2.         {
    3.             CmdCreatePlayer();
    4.         }
    Code (CSharp):
    1. [Command]
    2.     void CmdCreatePlayer()
    3.     {
    4.         GameObject g = (GameObject)Instantiate(objectToSpawn, Vector3.zero, Quaternion.identity);
    5.         NetworkServer.Spawn(g);
    6.         NetworkServer.ReplacePlayerForConnection(connectionToClient, g, playerControllerId);
    7.         ClientScene.SetLocalObject(netId, g);
    8.     }
    I put that in SmoothSyncExamplePlayerController.cs and it's always working for me. My objectToSpawn is a copy of the player prefab with altered color to tell the difference. I can move that around and see it on all systems (tested on 3 systems at once).

    I'm not sure what I can find out on my end if it's happening randomly. Do you have any other tips on how to recreate the issue?
     
    Last edited: Jun 14, 2018
  33. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine

    Unfortunately, I have never been able to get the glitch to occur on LAN or through the network simulator. It mostly occurs on the matchmaker (NAT punch threw) server with higher pings. If you find a solution please let me know these network transforms are crazy laggy!
     
  34. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @IdiotsCode
    Are you using our Matchmaking and NAT Traversal assets or Unity's built in one from the legacy networking system?
     
  35. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
  36. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    This is the only error that appears when this bug occurs
    Code (CSharp):
    1. Unknown message ID 32765 connId:1
     
  37. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @IdiotsCode
    Does the error just show once or is it a bunch of them? I'll test in conjunction with our other assets and over some real network and see if I can get it to happen.
     
  38. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine
    A bunch, it seems to be happening more in the EU. I believe its an issue with the registering not always being called (1073 - 1096, smoothsync)
     
  39. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @IdiotsCode
    Found it! Or at least I definitely fixed a problem that produced the same error and now it doesn't anymore. I'll probably just be updating NAT Traversal so it doesn't need this monstrosity. Sorry about the issue and thanks a ton for bringing it to my attention.

    For now, change your OnStartClient() to be
    Code (CSharp):
    1. public override void OnStartClient()
    2.        {
    3.            if (!NetworkServer.active)
    4.            {
    5.                var natNetworkManager = (NATTraversal.NetworkManager)NetworkManager.singleton;
    6.                if ((natNetworkManager.directClient == null || !natNetworkManager.directClient.handlers.ContainsKey(MsgType.SmoothSyncFromServerToNonOwners)) &&
    7.                    (natNetworkManager.punchthroughClient == null || !natNetworkManager.punchthroughClient.handlers.ContainsKey(MsgType.SmoothSyncFromServerToNonOwners)) &&
    8.                    (natNetworkManager.relayClient == null || !natNetworkManager.relayClient.handlers.ContainsKey(MsgType.SmoothSyncFromServerToNonOwners)))
    9.                {
    10.                    natNetworkManager.RegisterHandlerClient(MsgType.SmoothSyncFromServerToNonOwners, HandleSyncFromServerToNonOwners);
    11.                }
    12.            }
    13.        }
    Let me know if you have any questions, problems, or comments.
     
    Last edited: Jun 15, 2018
  40. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine
    Amazing! Works like a charm.
    Thanks a ton
     
  41. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine
    Ugh, the bug is back but this time with no debug log errors (same stuff some players not moving on other players screens)
     
  42. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
  43. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
  44. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
  45. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    @Fuestrine Hey :) I just updated to the latest version (v3.0) and am having a slight issue...

    I used the "Reset" option on all my instances of the SmoothSync script so everything is at the defaults, and I am now getting some undesirable behavior. It seems my players' moves are delayed by a good second or two and it moves in bursts, rather than smoothly as it was in the previous version. Like, when I press forward to move my character, it takes a second or two to move on the second client, and when it does actually move it's really jerky as in: it moves a bit, freezes, moves a bit, freezes, etc.

    So, are the defaults no longer good values to use? Or perhaps it's just something wrong with my project?

    Thanks!

    EDIT: Scratch that... It seems to only be an issue when playing in the Editor. Guess maybe some sort of performance issue there... It seems to be working great when using built players only. Thanks anyway. :)

    EDIT 2: Oh, I guess I do have another question though... One thing I am noticing is my character always smooths to a stop on other clients, whereas on my local client it pretty much instantly stops (which is how it was intended). Is there any way to address that? But perhaps I'm just being too picky in that instance... :p
     
    Last edited: Jun 20, 2018
  46. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @Jick87
    Hmm.. I'll have to take a look at performance in the new one. Thanks for bringing it to my attention.

    I'll also take a peek at how I'm stopping the movement to see if anything can be improved.
     
  47. RayanKheloufi

    RayanKheloufi

    Joined:
    Apr 27, 2018
    Posts:
    10
    Hello Fuestrine !
    I'm very sorry if my question is stupid, but I've been stuck for several hours, and I wonder if you've ever encountered the problem that I'm facing.

    On my game, I have players who can pick weapons. Once picked, they start levitating.
    I put your Smooth Sync on my player and my weapons prefabs (so their position should be updated around the network). The thing is, it works amazingly well with the players, their position is updated to every clients and stuff, but the weapons' position is updated to the clients only if the host picks it.
    I really don't understand, because this should not depend on my code.
    As I understood if a gameObject moves in a client, it should move everywhere, I just put the SmoothSync script and nothing else to think about. Why is it working when a Host picks a weapon and doesn't work when a client picks one?

    Thank you very much for your time!
     
  48. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @pikaray_unity
    No problem at all. It sounds like your objects are owned by the server. Smooth Sync takes the position on owners and smoothly syncs it to non-owners. It has to have some way to know who has authority over the movement. Your players objects probably already have ownership set up because Unity will do it automatically through the NetworkManager.

    I'm not entirely sure of your situation but for most typical FPS type games with weapons, I would say you wouldn't constantly sync the positions of the weapons across the network and you would just sync the players. I would send over an RPC that tells that weapon to become "attached" to the local version of that player on all systems.

    If you do want to track the positions of the weapons constantly, you might want to change the weapon's owner when you pick it up. Another way would just be sending a CMD to the server to tell the server to attach it to the server's local version of the player who should be picking up the weapon.

    Let me know if any of that was confusing or if it doesn't answer your questions.
     
  49. RayanKheloufi

    RayanKheloufi

    Joined:
    Apr 27, 2018
    Posts:
    10
    Well, turned out you were right, I reached the effect that I wanted by implementing this idea, and it magically updated the weapon's location (even in levitation) among all clients.

    Thank you very much for your quick and useful answer!
     
  50. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    569
    @Jick87
    I don't see much I can change to make the editor run better or anything that changed recently that would make it run much worse. About how many objects are you syncing at once? It might be time to take a look at all of the tiny things I'm doing to see if they can add up into some editor performance savings.

    If you want your object to stop faster, try turning PositionLerpSpeed to 1. It should look better at 1 than it did before the 3.00 version. Also note, 3.01 came out pretty recently so check that one out.
     
    Last edited: Jun 23, 2018