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

    farshmak

    Joined:
    Jun 17, 2014
    Posts:
    3
    Terrific reply! Holy moly it worked!
     
    Fuestrine likes this.
  2. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Micahdog
    Yep, just send out CMDs and RPCs to change the syncing mode on everyone. Try it with calling SmoothSync.clearBuffer() too on everyone probably. Make sure to set the velocity the same way or you'll be extrapolating in those directions still.
     
  3. Justin_Wingfall

    Justin_Wingfall

    Joined:
    May 15, 2014
    Posts:
    125

    if you dont mind me asking where actually do I do with this code, do I simply make a new script? Or add it to a photon or smoothing sync script?
     
  4. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @trey-j
    Paste it into SmoothSync.cs as a method. You'll probably be extending SmoothSync.cs from some Photon stuff instead of Unity's NetworkBehavior. Then you'll need to delete or convert the things that yell at you about how it's Unity's networking API to the Photon API. Deserialize() on State.cs now takes the game object in as a reference so you won't be searching for the object using Unity's networking, you'll just be passing it in. You'll see it commented on where to use it.

    It should all be pretty well commented but let me know if you think they don't fully explain anything.
     
    Justin_Wingfall likes this.
  5. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine,
    I've been using this plugin for a good deal of time now but still run into issue's using it with 2d physics objects. Often at speeds more than 5 u/s the objects will start to jitter and become very inaccurate, how would one go about fixing this?
    Capture.PNG
    Those are the config's I'm using, any help would be greatly appreciated.
     
  6. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @IdiotsCode
    I don't see anything wrong with your settings. I don't get this issue in the example scene when I turn the speeds up to about 15 u/s either.

    Are they becoming jittery just moving along or are they bouncing off of other colliders?

    I would try upping your position snap threshold.

    If that doesn't work, can you try to recreate the issue in the example scene or send me a small project with steps to recreate the issue?
     
  7. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine, Heres an example project,
    arrows keys to move https://www.dropbox.com/s/tbofcknl43p271j/SmoothSyncVelocityTest.zip?dl=0
    The jitter in this is much much better than in-game, not to sure why I might have to do a reimport, but you can see some of the issues at speeds around 20u/s although I think that that's mostly the snap. In the actual game itself, I use point effectors for "gravity" is it possible that that is the issue?

    EDIT: Just updated the Dropbox project to fix up some camera weirdness
     
  8. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @IdiotsCode
    One issue might be that you are updating your extra "gravity" on non-owned objects. You only want to use "gravity" on owned objects which will then mirror out to the non-owned objects.

    Let me know if that or increasing the snap threshold fixes or doesn't fix your problem.
     
    Last edited: Mar 7, 2018
  9. IdiotsCode

    IdiotsCode

    Joined:
    Aug 23, 2015
    Posts:
    15
    @Fuestrine,
    Yup increasing the thresholds did help quite a bit (It appears to have been mostly the gravity's fault), theres still a good deal of jitter and inaccuracy but its much much better.
    Capture1.PNG
    Any ideas on how to get around these errors or is that just going to be a small inaccurcy thats not fixable?
     
  10. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    How do I go about teleportation object with smooth sync?
    Right now if I try it you can see the object lerp from the first area to the teleported area.
    Is there a certain way to do it or am I to turn off the component then move it then turn it back on?
     
  11. Alkanov

    Alkanov

    Joined:
    May 15, 2017
    Posts:
    54
    Hi,

    Is there a way of making pos sync authoritative? Because at the moment I can use "speed hacks" and it is reflected in the server/other clients

    Edit: I guess syncing the controller instead of pos would work, but from what I understand, it is ideal to let the client control his own playerObject so their movement reaction is not affected by the delay client<->server. Is there any function that I can call to let a client know that it needs to re-adjusts (interpolate) its playerObject position due to a big discrepancy (position) between client and server?
     
    Last edited: Mar 6, 2018
  12. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @IdiotsCode
    At speeds of 21 units per second, I think you are just going to see it be more off. It's already off by the InterpolationBackTime you set. So if it's at .2 seconds in the past and you go 21 units per second, it will be more than 4 units off and that is all on purpose. You can lower the InterpolationBackTime if you want but this will create more bad experiences during minor network lag.

    As far as Jitteriness, try changing WhereToUpdate to Update instead of FixedUpdate. I don't really recommend it but that's usually what people talk about when they say it's jittery and that's just a limitation on Unity's Fixed Update.

    Let me know how it goes.
     
    Last edited: Mar 6, 2018
  13. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    Check out the example scene. I have a teleportation example in the example scene playercontroller script. Let me know if you have any problems.
     
  14. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Alkanov
    To make position determined by the server you will need to have the object owned by the server. Spawn it or change it's authority.

    Player Prediction is beyond the scope of this Asset. I assume SmoothSync is a pretty good base to try to turn things off and back on and some extra lerping but it's not something I'm looking to do. I'd be happy to answer specific questions along the way though if you wanted to try something.

    "Is there any function that I can call to let a client know that it needs to re-adjusts (interpolate) its playerObject position due to a big discrepancy (position) between client and server?"
    Check out the snapThresholds and maybe the receivedThresholds. Lots of things affect position so I would just trace it back from the SetPosition() methods and see if you want any of that other stuff.
    My initial guess of trying to make your own Player Prediction would be instead of it "snapping" with the snap thresholds, maybe you just want to lerp? Then you will have it not update from the server at all except for this lerping? No clue, that sounds kind of insane actually, good luck, lol. Let me know if you have any questions.
     
    Last edited: Mar 6, 2018
  15. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    OK, I found the script you are talking about.
    I took a look and the only problem is this object is not a player object.
    It is a projectile that comes from an object pool.
    How would I go about making that work with no local authority?
     
  16. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    It being a player object shouldn't matter. The only changes are that you are already on the server and the owner so you won't be sending any teleport commands from the clients to the servers.
     
  17. FreddyJoestar

    FreddyJoestar

    Joined:
    Aug 19, 2017
    Posts:
    2
    Hi Fuestrine!
    I wrote you this same post as a message but I thought I could also post it here.
    I implemented Smooth Sync in my project and I am having trouble with the collision of a non-player object.
    The game is a basic rectangle in which two players can bounce a ball back and forth between each other. The ball moves at a hard coded, constant speed and that way never stops moving. The movement of the players and ball are nice and smooth but something peculiar happens on the clients side. The ball's position is sent reliably but the ball never touches any of the colliders. While at the localhost the ball bounces off a wall, on the clients side it comes to a stop shortly before it collides and then synchronizes with the movement on the localhosts screen again. It looks like the ball is stopped by a 'magnetic field' anytime it approaches a collision.

    Do you know how I could find a solution to this problem?
     
  18. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @FreddyJoestar
    You're going to have problems doing literal object collisions if you want client authority. Basically, in a perfect system, you'll never get the positions to actually collide since with perfect tracking, the objects would only go to the collision point and then reflect off the collision point. So they never actually collide since they aren't going into positions they have never been. What you are probably seeing is your server side ball collide with the player which is going to look off on your client.

    If you want perfect collisions you'll have to make all of the objects owned by one system so that they can collide like normal and then send the position information out.

    A lot of networking is just hiding imperfections. One plan could be to try to have it run with the clients owning the objects and then send over an RPC that does .AddForce() and have a small wait time before the collisions occur, you can throw out some particles and do a bit of a freeze before the hit. It's not too unlike how they pause a bit on the hits in fighting games. With any luck, this will make your game feel more powerful anyway.

    Let me know if I misunderstood or if you need further explanation.
     
  19. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    Forgive me I am pretty new to UNET so I am still doing a lot of learning.

    Say a player that is not on the server issues a command to create a projectile.
    When I create the projectile I am also calling teleport on the projectile object.
    And the code would be something similar to this?

    Code (CSharp):
    1.         public void Teleport(Vector3 pos, Quaternion rot)
    2.         {
    3.             if (isServer)
    4.             {
    5.                 int timestamp = NetworkTransport.GetNetworkTimestamp();
    6.                 // Teleport owned object
    7.                 smoothSync.teleport(timestamp, pos, rot);
    8.                 // Tell host to tell non-owners to teleport
    9.                 RpcTeleport(timestamp, pos, rot);
    10.             }
    11.         }
    12.  
    13.         [ClientRpc]
    14.         public void RpcTeleport(int networkTimestamp, Vector3 pos, Quaternion rot)
    15.         {
    16.             // Don't teleport on owners because they already did.
    17.             if (isServer) return;
    18.  
    19.             smoothSync.teleport(networkTimestamp, pos, rot);
    20.         }
    Because this does not seem to work.
     
  20. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    First thought is maybe give a second for the object to spawn on the clients before trying to send an RPC on that object.

    Your code seems good there though, but I'm not really sure about the isServer, I don't use that, it's really just an authority thing anyway. It seems like it would work in your case but I would just stick to how I wrote it for now. There are also many nuances to UNET like you can't call CMDs on unowned objects.

    I would start by copying and pasting the entirety of my teleport code onto your player object and it should just work automatically. Leave the CMD part in and slowly take things out if you want to try to strip it down. Though leaving it as-is isn't hurting anything.

    In order to see your exact situation (I think) you can go into the example scene and uncheck "local player authority" on the player prefabs, the server will then own all objects. Press "T" on the server to teleport all server owned objects and it will then teleport on all clients as well (who don't own the objects).
     
    Last edited: Mar 7, 2018
  21. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    I was able to get the teleport working using a custom solution with SyncVars.
    Not the most elegant but it works.

    Now the problem is if I move my character and shoot at the same time all looks great on the server but on the client the bullets are kind of lag behind.
    You can see what I mean in this video.



    What can be done to correct this behavior?
     
  22. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    Was copying and pasting my solution not working for some reason? I don't know what you are using SyncVars to teleport for, so keep in mind that's different than I recommend so you might see unexpected behavior. But I don't see how that would be affecting this situation right here.

    I can't really tell if it's just spawning later or it's because you are moving and not adjusting bullet speed correctly. If you change to NetworkTransform and the problem goes away, let me know because it might be my problem.

    I would also change the bullet speed if you are moving to look better anyway. It's like if you are inside a bus and throw a ball forward. Technically that ball is going the speed of the bus + the speed of your ball since your ball needs to be going faster than the bus in order to reach the front of the bus. I can't think of any shmup that doesn't do this.

    One other thing to look at is InterpolationBackTime could be making the bullets appear in the past comparatively.
     
    Last edited: Mar 8, 2018
  23. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    If I copy and paste your solution the client is never called.
    I am using an object pooler to get the object.
    Then NetworkServer.Spawn to spawn the object.

    Just to show you the movement is fine on the server here is a video with that.



    Here is the code I used to get the teleport to work with a network pooler object in case someone is interested.

    Code (CSharp):
    1. using Sirenix.OdinInspector;
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using UnityEngine.Networking;
    7. using Smooth;
    8.  
    9.  
    10. namespace TryingNetworking
    11. {
    12.     public class TestProjectile : SerializedNetworkBehaviour, INetworkPoolerObject
    13.     {
    14.         public SmoothSync smoothSync;
    15.  
    16.         [SyncVar(hook = "OnTeleporting")]
    17.         public bool isTeleporting = false;
    18.  
    19.         public bool hasTeleported = false;
    20.  
    21.         [SyncVar]
    22.         public int teleportTimestamp;
    23.  
    24.         [SyncVar]
    25.         public Vector3 teleportPosition;
    26.  
    27.         [SyncVar]
    28.         public Quaternion teleportRotation;
    29.  
    30.            
    31.         public virtual void Awake()
    32.         {
    33.             smoothSync = GetComponent<SmoothSync>();
    34.         }
    35.  
    36.         public virtual void OnEnable()
    37.         {
    38.             if (!hasTeleported && isTeleporting)
    39.                 ClientTeleport();
    40.         }
    41.  
    42.         public virtual void OnDisable()
    43.         {
    44.             hasTeleported = false;
    45.             isTeleporting = false;
    46.         }
    47.  
    48.         public void Teleport(Vector3 pos, Quaternion rot)
    49.         {
    50.             int timestamp = NetworkTransport.GetNetworkTimestamp();
    51.             // Teleport server object
    52.             smoothSync.teleport(timestamp, pos, rot);
    53.  
    54.             teleportTimestamp = timestamp;
    55.             teleportPosition = pos;
    56.             teleportRotation = rot;
    57.  
    58.             hasTeleported = true;//Client has already teleported
    59.  
    60.             isTeleporting = true;        
    61.         }
    62.  
    63.         public void ClientTeleport()
    64.         {
    65.             // Don't teleport on server because they already did.
    66.             if (hasTeleported)
    67.                 return;
    68.  
    69.             smoothSync.teleport(teleportTimestamp, teleportPosition, teleportRotation);
    70.             hasTeleported = true;
    71.         }
    72.  
    73.         void OnTeleporting(bool isTeleporting)
    74.         {
    75.             this.isTeleporting = isTeleporting;
    76.  
    77.             if (!hasTeleported)
    78.             {
    79.                 ClientTeleport();
    80.             }
    81.         }
    82.     }
    83. }
    84.  
    I will play around with it and see if I can get it looking better.
     
  24. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    I don't understand how it's not working since I can recreate teleporting server owned objects using the example scene, but as long as you got it all working, it's all cool.

    As far as the bullet spawning late there, it seems like it's just taking a bit to send the call to the server to teleport the object and then for the message to get back to you while you are moving around.

    It seems like it could be just a normal limitation of networking. If it works better with NetworkTransform, let me know and I can see if it's a specific Smooth Sync problem.
     
    Last edited: Mar 9, 2018
  25. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    Although I'm new at this I'll give my thoughts on why the code in the example is not working.

    the function:
    public void teleport(Vector3 pos, Quaternion rot)

    has if (!hasAuthority) return;

    That means this code will never run because server spawned object will not have authority.
    The object is just being enabled because it came out of the pool.
    Even it it will have authority once it reaches the OnStartAuthority() it won't when Teleport is called. Possible if I added something in the OnStartAuthority() method maybe.

    I have tried getting rid of that line but then you have a command and that can't be run without authority.
    I have also tried just calling the RPC directly but the client never receives the message.

    Not sure if you have ever delved into network object pooling or not but it is a little different than regular pooling.

    Check this out if you are interested:
    http://www.justjuank.com/network-object-pooling-for-unity3d/
     
    Last edited: Mar 9, 2018
  26. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @katasteel
    OK, it all makes sense now. I mentioned earlier that you can't call CMDs on unowned objects, it seemed like you were trying to do that. Networking can get complicated pretty fast.

    Server owned objects have authority on the server and RPCs only send out from the server. In order to get an RPC call on a non-owned object from the client, you usually use a locally owned object to send a CMD to the server and then the server will call an RPC in order to propagate the message out to all of the clients.

    It's good to know it's a bit confusing for new people though, I'll have to go back in and see if I can make the example more coherent. Thanks for the idea!
     
    Last edited: Mar 9, 2018
  27. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    Hello,
    I am proffiling my game, and noticed that SmoothSync makes a little spike every X seconds at "CG Alloc" why is that ? is it avoidable ?
    As i said earlier i got a few units running around so every little optimization is welcome.
     
  28. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Paradoks
    I see it infrequently in the editor but I don't see it at all in a build. Unity does not suggest profiling in the editor for the most part.
    If this issue can be recreated using a build, let me know and know how to recreate it. Otherwise I just chalk it up to the editor being super funky.
     
    Last edited: Mar 14, 2018
  29. Avedis

    Avedis

    Joined:
    Jan 12, 2013
    Posts:
    24
    This asset seems to work great! I had posted before with an issue I thought had to do with building headless linux servers but it was a misconfiguration on my part.
     
    Last edited: Mar 15, 2018
  30. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Hey there, I just bought this and had a question. I'm guessing I probably have to add this to my server side as well? I can't just add it in the editor on my prefab and connect to my server and use it?

    Does this allow for Authorative Server? I use uMMO and when I use their plugin I end up slowly gliding for a few seconds as if the floor was a bit slippery, it doesn't look like server lag / jerkyness from high ping, it is a very smooth glide.

    I need authorative because my game is an rpg, but I also want it nice and smooooooth, lol.

     
    Last edited: Mar 16, 2018
  31. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MostHated
    The SmoothSync script must be on every instance of an object you want to network Smoothly. It must be on the server as well as all clients.

    Your question was a little confusing to me so let me know if I misunderstood or if you have any problems.
     
  32. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    What I meant was I have a build of my server that is already uploaded that doesn't have smooth sync on it, so for it to work properly I was guessing the server side needed to be rebuilt with the smooth sync component on it as well as the client side.
     
  33. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MostHated
    Yep, you'll need to rebuild it with the Smooth Sync script on the object.

    It works with an authoritative server. Definitely let me know if you have any sliding issues like with the other one.
     
  34. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Ok great, thanks, that is probably what my issue was. I tried to just pop it on my local prefab but then was no longer able to set server authority, probably because it was not in sync with the prefab that was on the server. I will do a rebuild of the server now and give it a go.
     
  35. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I noticed in the demo video the sphere didn't have a Unity Network Transform on it, just the Smooth Sync but the instructions say to add it to an already networked object. Is it required to have the network transform component as well, or is it completely "in place of"?

    Lastly, My character is set up in such a way that the parent object has all my scripts, animation controller, etc, but my mesh render is a child object of the parent, does that need to be synced as well? What about the hierarchy of character bones and such?


    ---- Edit. I had some other issues I ran into last night but finally got it setup. I removed the ummo network transform plugin so I could use smooth sync, but, well. It isn't acting very smooth. : / I am hoping I just didn't have something set right. I tried to show all my settings in that first video. It is strange how when I run forward it always seems like it is going "right, right, right, left, right, right, right, left". In the second video, hes spazzing so hard it seems like hes going to explode.

    Any actively counting error messages have been fixed, there are a few missing things here and there that are unrelated that were there before, nothing major.





    Here is the same setup, just turning off smooth sync and turning the ummo plugin back on. Back to how it was before with the sliding at the end.
     
    Last edited: Mar 17, 2018
  36. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MostHated
    Yes, just the SmoothSync component, you will no longer need the NetworkTransform component. I'm not sure what ummo is but you should not be needing their NetworkTransform equivalent either.

    Take a look at the example scene and it'll show you how to hookup children. You'll need one SmoothSync component for each object you want to sync. It basically works exactly like NetworkTransform and NetworkTransformChild except they are both in SmoothSync as one. The script is also commented fairly thoroughly for each variable. The one for childObjectToSync is
    Code (CSharp):
    1. /// Leave blank if you want to sync this object.
    2.         /// In order to sync a child object, you must add two instances of SmoothSync to the parent.
    3.         /// Set childObjectToSync on one of them to point to the child you want to sync and leave it blank on the other to sync the parent.
    4.         /// You cannot sync children without syncing the parent.
    That movement doesn't seem good that's for sure. My initial guess is that you have some other things affecting movement on there. I would try taking off all other networking or movement type scripts on it and have your client side movement only determined by SmoothSync. Then probably add things back on and build your way back up so you can get a better idea of what may be affecting the movement client side.

    Also, if you can use Unity's NetworkTransform instead of SmoothSync and Unity's NetworkTransform works while SmoothSync doesn't, I'd be happy to poke around your project myself because that basically guarantees it's a problem with my plugin.
     
    davidheeren likes this.
  37. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    That's the thing, I wasn't sure if I needed to have my mesh set as a child or not. I guess it doesn't hurt to test it.

    I will try a few things and see what happens. Both the standard Unity transform sync, and the ummo interpolation sync plugin do not have this issue (just the slight sliding I originally showed). I will try whatever I can I guess.Do my settings look ok?

     
  38. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MostHated
    Yeah, your settings seem fine to me. Also, the default settings should work with pretty much all situations(it just won't be finely tuned) if you feel like your settings are off again.

    Not sure what you mean by your mesh but if you have an object with a mesh on it that acts independently of the parent that you are syncing and you want it to send its updated positions across the network then I would sync it.
     
  39. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Ok, so it seems that anytime smooth sync is in fact active, as well as in authoritive it does this same weird bounce up and down and the zig zag walking. When local is on, it doesn't do it, and it doesn't do it with either of the other two plugins (ummo transform interpolation and standard unity transform sync). I thought maybe it was FinalIK that was causing the issue, but I disabled it on both sides and nothing changed. There is nothing else on my player does anything with movement. What do you recommend? When looking on the server side, the character is just hanging out there with no problem, which is strange.
     
    Last edited: Mar 17, 2018
  40. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Update, I am definitely on to something here now.

    It looks like all of the jumping around has to do with the position thresholds. The received ones were at 0,0. Here is my adjusting them clientside. It changes the bouncing and you can end up seeing it snap back. It looks like I might be like, slowly falling through the floor or something. I disabled the terrain and there is only the server side terrain colliders on here.

    This is quite baffling though. Only on authoritive and while using your asset do I start to slowly go downward. If its Local auth its fine, if I use the other ones, fine. I moved the terrain collider down by 1 and my person began to fall a tad, so he was on it, touching it, but what about your asset is making him continue to go down through it, especially when on the server side he is just standing there fine.

     
    Last edited: Mar 17, 2018
  41. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MostHated
    I don't get these problems in the example scene on an authoritative server with a client owned object or a server owned object. It sounds like gravity is being added client side when it should only be added server side. Using Unity's built in gravity should not affect anything like this but maybe you have code doing something?

    One thing that might help figure out if it's that, would be to change the variable WhereToUpdateTransform to Update and then in code (line 492 in SmoothSync.cs) to LateUpdate(). Then, unless you are using LateUpdate() to change position (or add gravity) elsewhere I want to say this should kind of fix the problem since at least the final position would be determined by SmoothSync. This isn't really a solution but it'll help maybe find the real problem.
     
  42. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Ok, no problem I will try this out. As for anything that would be making me move, no, I triple checked. I also made sure to check the gravity on both sides, which if I were standing on colliders should not make a difference anyway. I was once playing around and have it like -200, you still just stand there. Good luck trying to walk anywhere though, lol. I will try your suggestion now though!
     
  43. Dalilon

    Dalilon

    Joined:
    Nov 23, 2013
    Posts:
    1
    hello,
    First of all, sorry for my bad english.. ist 7:00 am and i´m trying for 30hours now to solve this Problem..

    I bought SmoothySync but now having a little problem, hoping you could help me :)

    I´m devoloping a game, where the Control is pretty much like in a first-person-shooter

    Everything works fine - till i try to make the game server-authoritive (trying for days but dont get it smoothly)

    The main Problem: if i just send the Server the Input of the Client - the lag when walking or turning around is too much - just feels unsmooth...

    so i tryed to move/rotate on sever and Client (like Client side prediction) and activate the threshold (think it´s exactly for that?) so both rotate, and if everything works fine at the end of the move they are so Close nothing happens -> just sync the other players

    ist ok with walking... but i dont get it working with rotating.... ist just laggy as hell - Server trying to correct the Client all the time

    is there any Chance to make this working server-authoritive with Client side prediction?
     
  44. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Man, it just makes 0 sense to me, still nothing. I am using Opsive TPC, the only thing else I have on me is Inventory Pro and then Horse AnimSet Pro but it doesn't do anything unless you press the mount button near a proper animal. I have FinalIK, but its all disabled and has been. Then the uMMO plugin and Smooth Sync. I have a feeling that even though I turn off ummos plugin, maybe the fact that it serializes stuff might have something to do with it? I wonder if I can go in and disable serialization just for transform. If it weren't for all these tons of inconveniences, ummo would be good, but its one thing after another.

    I need to find an alternative before I get too deep into my multiplayer.
     
  45. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @Dalilon
    "Client side prediction" or "player prediction" is beyond the scope of this asset. When the server owns an object that you want controllable by the player, you'll have to wait for your message to get to your server and then a message to go from the server back to the client before you see any changes.

    I would just make your players client owned. There's examples of client owned players in FPS type games. The Division is one. Server owned players don't even solve most cheating. That's why Steam has their anti cheating software. Unless you are planning to account for everything, which includes knowing locations of any other players if they are behind any walls (wall hacking), there is going to be a way to cheat anyway. Things like auto aim aren't solved by having your player server owned either. As far as my understanding goes, the only problem it solves would be literally moving your player around faster than you would normally, but this can also be solved by kicking any players who move too fast as determined by the server.
     
    Last edited: Mar 18, 2018
  46. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    @MostHated
    I would guess that it's Opsive TPC that's adding gravity manually since player controllers are rarely rigidbodies. Try searching that script or scripts for "gravity" and hopefully they comment well or name their variables well. Then don't do the gravity addition on unowned objects. Really I would think the plugin would already be doing this but it's all I can think of. uMMO could be trying to sync the object itself, but I would think you would have to hook it up to it somehow for it to even know the object so you should know if you are using that or not with it.

    I'd be happy to take a look at your project if you want to send it over to the support email with some instructions on how to recreate the issue. Since you said NetworkTransform works with it, it sounds like it's my problem. At the very least I like to have SmoothSync work in all instances where NetworkTransform also works.
     
  47. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Long post incoming, lol. Opsive is a rigid body controller and I don't see anything that's set that would be affecting it any, and I have not changed those settings here in the pic in about a year, lol. Though, that does remind me, a sticky in the Opsive TPC thread has a smooth synced transform script that one of the members made and shared with everyone. It might be worth grabbing it and giving it a try to see if I have the same outcome. I messaged you in regards to taking a look at my project, hopefully it doesn't come to that, especially since my project is about 92gb and it takes forever to export, zip, and upload, lol (more like 25gb I guess though once you take out library, .git repository, etc, but still.)

    As for uMMO's setup, there is a fairly major script that ends up integrating nearly everything about the network aspect that you put on the player, which is what ends up having the drop downs for what plugins you want to use, which is then derived from a controller prefab in the scene which ends up having all the other major components on it as seen below the Opsive TPC pic.


    ----------------- Edit - - I got a very interesting error when I implemented the Network Sync that was shared on Opsive's forum :

    Code (CSharp):
    1. [Error] OnDeserialize failed for: object=Player_M1(Clone) component=NetworkSyncTransform sceneId=0 length=0. Possible Reasons:
    2.   * Do NetworkSyncTransform's OnSerialize and OnDeserialize calls write the same amount of data(0 bytes)?
    3.  * Was there an exception in NetworkSyncTransform's OnSerialize/OnDeserialize code?
    4.   * Are the server and client the exact same project?
    5.   * Maybe this OnDeserialize call was meant for another GameObject? The sceneIds can easily get out of sync if the Hierarchy was modified only in the client OR the server. Try rebuilding both.
    6. System.IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:0 pos:0
    7.   at UnityEngine.Networking.NetBuffer.ReadByte () [0x00000] in <filename unknown>:0
    8.   at UnityEngine.Networking.NetworkReader.ReadUInt32 () [0x00000] in <filename unknown>:0
    9.   at UnityEngine.Networking.NetworkReader.ReadSingle () [0x00000] in <filename unknown>:0
    10.   at UnityEngine.Networking.NetworkReader.ReadVector3 () [0x00000] in <filename unknown>:0
    11.   at NetworkSyncTransform.OnDeserialize (UnityEngine.Networking.NetworkReader reader, Boolean initialState) [0x00000] in <filename unknown>:0
    12.   at UnityEngine.Networking.NetworkIdentity.OnDeserializeAllSafely (UnityEngine.Networking.NetworkBehaviour[] components, UnityEngine.Networking.NetworkReader reader, Boolean initialState) [0x00000] in <filename unknown>:0
    Which also made this happen D : I guess it had its way with my post processing or something?






    Here is the one that goes on the actual player ---------------------------------



    This one is the main uMMO plugin prefab that goes in the scene.



    Then this network manager is a child of the main uMMO plugin




    So on and so forth. The main problem is all the plugins have to inherit from the messenger class in order to be able to apply them. He said simply disabling the network transform plugin *should* actually disable it, but everything seemed to act exactly the same when I did, so I am not sure I am 100% convinced that it actually did that.
     
    Last edited: Mar 18, 2018
  48. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I am just going to disable all of ummos serialization and do something else about it completely so I dont have to worry about it. I honestly don't even know if I need it at all. Might have just been a waste of money.



    ------ Edit

    Great news!! After getting frustrated and disabling all of ummo, I tried it again, it still did the same thing. I wiped my library out, nothing. I have been using 2017.3.0f3 since it came out, I said screw it and updated to the latest one and... well, look below!

     
    Last edited: Mar 19, 2018
  49. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    589
    Yeah, it should work great for AI dragons.

    So what was the final conclusion? You got uMMO to stop sliding around without Smooth Sync by updating to the newest Unity? Or is that with Smooth Sync?
     
  50. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    That was with my removing uMMO and using smoothsync. It was working well.... until I tried it a second time and then it was doing the same thing again... so I guess I spoke too soon. It did work well though for that session in which I took the video, I just need to figure out what happened the second time I tried.