Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

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

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

  1. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    61
    Hello - I'm new to Smooth Sync and so far I'm very happy with it. I converted it to use Mirror and it is performing very well so far - but I do have one odd behavior I want to bounce off you.

    Background - In my scene I've got a few simple rigidbody cubes with smooth sync on them. The cubes are owned by the server but can be grabbed by any client and dragged around and smacked into the other cubes. Grabbing a cube does not change ownership - the grab drag code is in a [Command] that runs on server. This all works nicely.

    However when dragging a cube on a client, I will sometimes see the impact results before I see the impact. That is - I will see the cube in front of the one being dragged fly off into the air just a half second before the dragged cube reaches it. I do not necessarily think this is a mirror or smooth sync issue because I saw the same with plain UNET as well. Any ideas on whats going on here? Also worth noting, this usually only happens 2-3 times early in the game and then I cannot repro it at all.

    Anyway just thought I'd bounce it off anyone out there.

    Thanks
    Jake
     
  2. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @antsonthetree
    I could see it happening at a low enough send rate maybe. Or maybe the send rate is different for each object? Try raising the send rate to 30 for all the objects just for testing to see if you ever see it again.

    Another guess is that ownership isn't what you think it is, or maybe something else is moving the position of the objects on computers that don't own the objects. You seem to know about ownership and whatnot though, so it's probably not either of those. I'm out of guesses though. If you can recreate the issue at all, let me know and I'll try to recreate the issue on my end. Let me know if you have any questions.
     
  3. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    I have just completed a Mirror version of Smooth Sync!

    Unity should approve it in a few business days but if anyone wants it sooner, PM or email me (with your invoice number if we haven't talked before) and I'll send you it.
     
    antsonthetree likes this.
  4. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Arsonide @Richie_V @Clonkex @VrTechEx @Lachee_ @antsonthetree
    All of you have asked about Mirror support in the past.

    There is now an official version of Mirror SmoothSync available on the Asset Store. Update to the new version and unpackage the SmoothSyncMirror package.

    Let me know if you have any issues, questions, or comments.
     
    antsonthetree likes this.
  5. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    14
    I add the smooth sync script and it automatically add a NetworkIdentity of UNET.I'm now using Mirror.How should I solve this?
     
  6. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @jacknero
    It sounds like you may be using the UNet version of Smooth Sync.
    Unpackage the SmoothSyncMirror.package and add a SmoothSyncMirror component to your object.

    Let me know if this is not the issue.
     
  7. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    22
    @Fuestrine Hey Fuestrine, If I needed SmoothSync to stop all syncing of an object when the distance between remote objects and the server/ authority object is greater than a certain amount, how would I go about doing so? I know the obvious answer would be to disable the SmoothSync component? I guess, but I don't want to put a system in place to do that across the entire network. Or a tleast I'd like to avoid that overhead.
     
  8. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    61
    I think I resolved it by turning off smooth sync extrapolation. I don't see it any more so I'm good. I already had my send rate to 30 - that seems to be the default. Question - Is there a guide or doc with some standard settings for different scenarios?
     
  9. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
  10. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @antsonthetree
    If your extrapolation was causing the issue then you may want to raise your InterpolationBackTime a bit. But if you aren't seeing any issues with extrapolation off, then it may not be needed.

    There's no guide for different scenarios, but it's a good idea. I think I'll make a super reactive scenario and a super low send rate scenario. Any ideas for what you may like to see?
     
  11. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    22
    I suppose that does do what I asked somewhat, the problem with this component is it's part of UNet and not easily adjustable by me, just sticking it on causes all sorts of annoying things to break, even UNet HLAPI stuff like ClientScene.FindLocal breaks because of the proximity component.

    Maybe you can help me with my actual issue, it's not 100% related to smoothsync but rather syncing in general.
    My project is heavily based on physics.
    My character object, is spawned via NetworkServer.SpawnWithClientAuthority as a separate object to the one that represents the 'player'.

    My character Hierarachy consists of a TopLevel wrapper gameobject (For simplicity: MyCharacter), and inside this object is the physical gameobject of the character which has physics etc :)CharacterBody).

    This physics enabled part of the character is what SmoothSync is syncing across the network.
    (Think ragdoll, and SmoothSync is syncing the root of this ragdoll).

    So, let's say I have a player connected, and another one joins.
    When this new player joins, UNet creates an instance of the first character on the new players client as standard procedure. (A remote player/character)

    This is where my problems occurs, the syncing of my 'CharacterBody' pretty much explodes my characters without fail because the syncing is pulling the CharacterBody from the default start position to wherever that character actually is and breaking all the joint constraints in the ragdoll. So why dont I change the default start position? I can't figure out how to override UNets automatic spawning of objects when a new client connects. Now obviously UNet is spawning the 'MyCharacter' wrapper at the same place across the network, but it's my syncing solution that 'spawns' or moves the actual character which is where the issue gets complicated.

    Now I had this issue sorted at one point by moving the top level wrapper (MyCharacter) of newly created characters on clients to the position of their server CharacterBodies. But I cant get this work anymore as finding the right moment in the networking execution order when everything lines up is just.. ugh. Not working out for me.

    So I was thinking of implementing a clamp on syncing speed, or some higher level of control over the rate of syncing whether it be none at all or slower than what's defined by default etc.

    I've looked into UNet spawning documentation and can't find anything conclusive on where UNet handles the automatic spawning of character clones when a new client connects and it just spawns existing characters.

    I think it might be SpawnDelegates or maybe OnServerAddPlayer but its not clear? And as I said, I'm spawning the character as a separate object to the one defined as the 'playerPrefab', ironically for this very reason, in case Unity physics explode causing the gameobject to do god knows what, I don't want an unstable physics object representing the player on the network doh.

    TL:DR; Syncing physics ragdoll via root, if distance between characters is large, syncing breaks ragdoll when new client connects because of sudden physics snap. Maybe syncing through rb.MovePosition would solve this rather than transform.position =.
     
  12. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Hummy91
    It sounds like you could tie into Smooth Sync's SnapPositionThreshold. See in the code where that gets taken into account, and then also move all your objects and joints connected to your object to whatever default local position that makes it not be crazy when that gets used.

    If you are syncing an object with a rigidbody and set WhenToUpdateTransform to FixedUpdate, Smooth Sync will use rb.MovePosition() when not snapping to position. This is in setPosition() method if you want to mess with using rb.MovePosition() no matter what or anything like that.

    Let me know if that doesn't help.
     
    Hummy91 likes this.
  13. bingofly

    bingofly

    Joined:
    Sep 15, 2018
    Posts:
    24
    Hello
    Just bought this asset. I like it. In particular, it's compatible with mirror.
    After I import the package, there are many scripts. Could u pls tell me which ones should I keep for mirror? Then I will delete others.
    Another question: Is the NAT Traversal compatible with mirror too?
    Many thanks:)
     
  14. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @bingofly
    You will have no issues with using NAT Traversal with Smooth Sync.

    You should just need the "Required Internal Use Scripts" in the "Common" folder and the "Smooth Sync Asset" folder inside of the "Mirror" folder.
     
    Last edited: Feb 18, 2019
  15. bingofly

    bingofly

    Joined:
    Sep 15, 2018
    Posts:
    24
    @Fuestrine Hi There. After tested the SmoothSync Mirror, I found that there always be something wrong with sync movement when game just start. The remote player moved like it is teleporting. The bad situation lasted for 1 to 2 seconds, then the movement went back to smooth. I'm sure it's not caused by the low fps due to game initialization. Do you have any idea about the issue?

    Add another point : after a while(1 minute to 20 minutes), the remote player start to jitter during move, it's weird since everything is ok before.
     
    Last edited: Feb 19, 2019
  16. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @bingofly
    I believe what you are seeing is the first second's worth of information (States) that get sent over the network. This is so it can start out at a useful ping.

    Check out SmoothSyncMirror.cs line 2261
    if (receivedStatesCounter < sendRate ||

    You can mess around with lowering it. Maybe try "sendRate / 2" I tried at one point (forget what I lowered it to now) but some people had issues so I reverted back to a full second.

    If you lower it, you may want to look into raising your TimeCorrectionSpeed which is what is used to adjust ping after the first second's worth of information.

    Let me know if you have further questions.
     
  17. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @bingofly
    I'm not seeing your
    issue in the Smooth Sync Mirror Example scene. Does this happen in the example scene for you?
     
  18. bingofly

    bingofly

    Joined:
    Sep 15, 2018
    Posts:
    24
    Firstly I should lower the sendRate to "sendRate / 2", then "SendRate/4" and so on.
    Secondly I should raise the TimeCorrectionSpeed from 0.1 to some other value maybe 0.15.
    Then test it.
    Am I right? Sorry for my stupid.
     
  19. bingofly

    bingofly

    Joined:
    Sep 15, 2018
    Posts:
    24
    @Fuestrine
    When I test the example scene, NetworkIdentity debug an error as below:
    "Failed to find prefab parent for scene object [name:SmoothSyncMirrorPlayerPrefab]
    UnityEngine.Debug:LogError(Object)
    Mirror.NetworkIdentity:ThisIsASceneObjectWithPrefabParent(GameObject&) (at Assets/Mirror/Runtime/NetworkIdentity.cs:262)
    Mirror.NetworkIdentity:SetupIDs() (at Assets/Mirror/Runtime/NetworkIdentity.cs:276)
    Mirror.NetworkIdentity:get_assetId() (at Assets/Mirror/Runtime/NetworkIdentity.cs:93)
    Mirror.NetworkInformationPreview:GetAssetId() (at Assets/Mirror/Editor/NetworkInformationPreview.cs:252)
    Mirror.NetworkInformationPreview:GetNetworkInformation(GameObject) (at Assets/Mirror/Editor/NetworkInformationPreview.cs:218)
    Mirror.NetworkInformationPreview:Initialize(Object[]) (at Assets/Mirror/Editor/NetworkInformationPreview.cs:73)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Back to my scene, unchecking the check boxes of compression and testing once again for 20 minutes, the jitter didn't happen again.
    Maybe the compression is the reason? I'm not sure.
    I will keep watching and testing more times. Let you know if there's anything wrong.
     
  20. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @bingofly
    You should try "sendRate/2" in the code in SmoothSyncMirror.cs line 2261. You can try lower if it works, but I probably wouldn't go lower than sendRate/4. You'll probably see issues at sendRate/4 anyway.

    You may need to turn up TimeCorrectionSpeed, you may not. If you notice it's very slow to react in the beginning, it could be because it has some high ping in the start of your game from loading assets and such. That's why it waits for a second of movement by default.
    .15 is a good starting point for TimeCorrectionSpeed probably. You'll know you went too high when it gets jittery.

    Your error is probably because you deleted the Prefab earlier when you were asking about deleting not needed files. The example scene stuff is usually good to keep around so you can just look at a simple scene with just SmoothSync.
    Keep the entire "Common" folder and "Mirror" folder if you want the Example Scene stuff.

    I would think compression wouldn't make it be off from just moving for 20 minutes, but it could be if you go far away from the origin (0,0,0). There's more information if you mouse over the compression variables.

    Let me know if you have any questions.
     
  21. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,448
    Does this have any example scenes with Mirror setup demonstrating various things, rigidbodies etc ? just something I can build and test with straight away?
     
  22. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Player7
    Yes. It has a Mirror example scene that uses rigidbodies. You can take the rigidbodies off the player object in order to test non-rigidbodies as well.
     
  23. sumit176

    sumit176

    Joined:
    Feb 4, 2015
    Posts:
    1
    @Fuestrine Hi I am using SoothSync with PUN2. Can you help me understand the working of this plugin? does it work without having PhotonView component on Object?
     
  24. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @sumit176
    No, it needs a PhotonView. Take a look at the prefab in the PUN2 example folder for a working example.
     
  25. Captain_Flaush

    Captain_Flaush

    Joined:
    Apr 20, 2017
    Posts:
    30
    Hello,

    I have integrated smooth sync and works like a charm. I have the following question:
    Locally for my player I do something like this:
    - Get Input (move offset and move direction)
    - Animate based on the input (based on the move direction. Animation has no root motion)
    - Move based on the input (transform + move offset)

    On the client where I am not authority I an doing something pretty hacky.

    Vector2 newPos = new Vector2(transform.position.x, transform.position.z);
    moffset = newPos - lastPos;
    moveDir = moffset.normalized;
    lastPos = newPos;
    if (moffset.magnitude < 0.001)
    {
    moffset = Vector2.zero;
    moveDir = Vector2.zero;
    }

    Things work, but do you have a cleaner way of computing the move offset from smooth synch.

    Thanks!
     
  26. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,448
    Seems like the asset hasn't been updated for 2019_.. because Unity have stripped out UnityEngine.Networking in all 2019 releases ..and you still have so many references UnityEngine.Networking when it should be 'Using Mirror;' so some stuff to migrate I guess....
     
  27. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Player7
    Correct. I do not support beta versions of Unity, I only support production versions of Unity. Thanks for the heads up though. I'll be on the lookout to update at some point as 2019 can't be too far away.

    If you have any specific questions about updating it to beta Unity yourself, let me know.
     
  28. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,448
    well yeah I do can you please update it I'm using 2019.2a6 now and 2019.1 beta is probably not far from RC, I mean you've gotta find a replacement for all of UnityEngine.Networking anyway might aswel get it fully Mirror ready.
     
  29. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Captain_Flaush
    I'm not entirely sure what you are asking but I don't really have a cleaner way to calculate the offset in position. Using Vector2.sqrMagnitude() will be faster in your calculations though and will probably work for you.

    Are you trying to get your animations to line up to the SmoothSync movement?

    You could try sending over an RPC to tell which animation to play and sending the Time.RealTimeSinceStartup with it. Then, when the interpolationTime passes your animation time that you sent over with the RPC you can play the correct animation. You'll probably want to make this variable public and move it out of the scope of ApplyInterpolationOrExtrapolation().
    Code (CSharp):
    1. // The target playback time.
    2. float interpolationTime = approximateNetworkTimeOnOwner - interpolationBackTime;
    One easier way to just be more on time in general and you can probably just send RPCs over to do animations without waiting for SmoothSync time to pass, would be to lower your InterpolationBackTime. Keep above 1/sendRate to be super smooth (not constantly extrapolating)

    Let me know if you have any questions or if that doesn't help and I misunderstood the issue.
     
  30. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Player7
    I think you are looking at the UNet code. There is only one reference to UnityEngine.Networking when using Mirror. It's in MsgType.cs and I think you can just comment it out and make it look like
    Code (CSharp):
    1. public class MsgType// : UnityEngine.Networking.MsgType
    to get it to work. It works in the latest non-beta or non-alpha Unity at least.

    You need to use the code in the Mirror package. Click to unpackage it, then use SmoothSyncMirror.cs on your objects. I'll update my README to make this a bit clearer.
     
    Last edited: Mar 2, 2019
  31. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,448
    ahh I see, I just imported the asset and didn't really look at what was importing and needed unchecking.. checked again and saw the Unet folder was imported, so yup out with that and imported Mirror and it's all working.

    Would be good if the example could be expanded with some more examples usages, only just getting started with Mirror/unet anyway so yeah.
     
  32. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Player7
    Good to hear that it's working.
    What example usages did you have in mind? There's not much to SmoothSync except stick it on the networked object you want to be smoothly synced.
     
  33. bingofly

    bingofly

    Joined:
    Sep 15, 2018
    Posts:
    24
    @Fuestrine Hi there,
    In the SmoothSyncMirror script, there's a function names SendStateToNonOwners, which has two traverses in it.
    The first loop is for NetworkServer.connections.Keys and the second loop is for observers of each connection.
    Maybe it could change to only one loop for observers, because the observers is only thing the synchronization cared.
    If I'm right, it is an efficiency improvement since we don't need to traverse all the connections as well as observers of each connecion is finite.
    I've changed it and seems no bug so far. But I don't know if there's any further issues that I did't think of.
    So my question is, can I change it?
     
    Last edited: Mar 6, 2019
  34. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @bingofly
    Great idea, thanks for bringing it to my attention. I further optimized it a bit too.
    Here's what I got:
    Code (CSharp):
    1. [Server]
    2.         void SendStateToNonOwners(MessageBase state)
    3.         {
    4.             foreach (var kv in netID.observers)
    5.             {
    6.                 NetworkConnection conn = kv.Value;
    7.              
    8.                 // Skip sending to clientAuthorityOwner since owners don't need their own State back.
    9.                 // Also skip sending to localClient (hostId == -1) since the State was already recorded.
    10.                 if (conn != null && conn != netID.clientAuthorityOwner && conn.hostId != -1 && conn.isReady)
    11.                 {
    12.                     // Send the message, this calls HandleSyncFromServerToNonOwners on the receiving clients.
    13.                     conn.Send(MsgType.SmoothSyncFromServerToNonOwners, state);//, networkChannel);
    14.                 }
    15.             }
    16.         }
     
    Last edited: Mar 6, 2019
  35. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    14
    Hi,there.
    I've just updated my Mirror to the latest version and got some problem.
    It seems every network object reports an exception in OnStartServer

    • Exception in OnStartServer:Object reference not set to an instance of an object at Smooth.SmoothSyncMirror.OnStartServer () [0x00067] in D:\Tephra-E\Assets\Smooth Sync\Other Networking APIs\Mirror\Smooth Sync Asset\SmoothSyncMirror.cs:1679
    • at Mirror.NetworkIdentity.OnStartServer (System.Boolean allowNonZeroNetId) [0x000fd] in D:\Tephra-E\Assets\Mirror\Runtime\NetworkIdentity.cs:254
    • UnityEngine.Debug:LogError(Object)
     
  36. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @jacknero
    I'm not seeing this issue in the example scene when using the latest version of Mirror on the Unity store. Does this happen in the Smooth Sync Mirror example scene for you?

    If not, can you say how you are spawning your object so I can try to recreate the issue on my end?

    What version of Unity are you running?
     
    Last edited: Mar 9, 2019
  37. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    14
    I use Unity 2018.3.8. and Mirror lastest master branch on Github.
    The Smooth Sync Mirror example scene works without exception for me.
    I use the NetworkManager's Register Spawnable Objects List to spawn scene objects.
    Seems only scene object can't be spawned right and player character which spawned manually after the server started works just fine.
     
  38. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @jacknero
    I see the same issue in Mirror when not using SmoothSync with an object already in the scene. The object appears inactive and it errors with:
    Spawn scene object not found for 27771354 SpawnableObjects.Count=1
    This comes before any SmoothSync errors and the object cannot be seen even without SmoothSync.
    I also don't see the issue when spawning with NetworkServer.Spawn() if that's what you mean by scene object.

    So this seems like a Mirror issue to me. Let me know if you think it's a Smooth Sync issue though or if you think I'm misunderstanding the issue.

    Also, for future needs I won't always be up to date with the latest Mirror on Github since they put out releases a few times a day, but this doesn't appear to be the issue here since it happens even when not using SmoothSync. I will be up to date with what they have out on the Unity store though as that seems like a more reasonable schedule and when they would be sure their code is stable.
     
  39. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    14
    Thanks for attention.
    I think they are two different issues.
    Just start the host with no client connected, there's still the exception when each Smooth Sync Mirror component of the gameobjects either in the scene or instantiated (as long as before StartHost) call the OnStartServer().(if a gameobject has two smooth sync mirror to sync a child,it will report exception twice)
    Network objects can't be spawned issue will happen when a client connect,the one I mention just happens on the host before that.
    The march 8 store version Mirror also has this problem.Perhaps it appears with some recent API change.
     
  40. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @jacknero
    I can't seem to replicate the issue when doing what you have said.

    Can you send me a project with the issue in it or can you list out the steps to replicate the issue using a basic scene?
     
    Last edited: Mar 9, 2019
  41. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    Version 3.17 has been submitted to the Asset Store. It should show up within a few days.

    Change log:
    • UNet and Mirror performance increase.
    • Added Unity 2019 support for non UNet versions.
    • Packaged up UNet so it doesn't conflict with Unity 2019.
    • Reorganized folder structure.

    Version 3.16 changes that I didn't post here yet.

    Change log:
    • Fixed issue with SnapPositionThreshold not taking effect when using VelocityDrivenSyncing.
     
    Last edited: Mar 11, 2019
  42. Scr4phead

    Scr4phead

    Joined:
    Jan 24, 2015
    Posts:
    2
    I have partly converted SmoothSyncPUN to work with TNet instead. Works with my use case for now. I am just throwing in an additional vote for official TNet support. :D
     
  43. toyhunter

    toyhunter

    Joined:
    Mar 5, 2018
    Posts:
    34
    Hi @Fuestrine

    Would you suggest the best way working with SmoothSync that moving a rigidbody, go forward to specific position then backward, with configurable speed? Imagine that object is a yoyo.

    I believe should not use addForce, I tried MovePosition with Lerp but result is bad...
    Also, what if shooting a bullet with configurable speed? Thanks a lot.

    Best regards
    HM
     
    Last edited: Mar 13, 2019
  44. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @hmpublic2000
    It shouldn't matter how you move the object on your owner. But only let Smooth Sync move the object on non-owners.

    If you're talking about your yo-yo changing directions between your Send Rate, which could look weird, try
    forceStateSendNextFixedUpdate()
    on your object's Smooth Sync which will force a State to be sent regardless of all of your other options.

    If neither of those seem like your problem, what's going wrong? Are you only moving it on the owner and it looks jittery on the non-owner? If so, try resetting to default variables. If that works, put your variable changes back one by one until you see where the issue might lie.

    Let me know how it goes.
     
  45. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @Scr4phead
    I'll think about it. Does TNet not have anything like Smooth Sync or were you just looking for something better and found Smooth Sync?

    If you have any specific questions while converting, let me know though.
     
  46. toyhunter

    toyhunter

    Joined:
    Mar 5, 2018
    Posts:
    34
    @Fuestrine

    Could SmoothSync handles moving a isKinematic rigidbody smoothly using MovePosition? Please let me know what do you think or the way to achieving this (if possible). Thanks :)
     
  47. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @hmpublic2000
    Yeah it works. I just used the example scene with the SmoothSyncPlayerPrefab Rigidbody set to isKinematic and using rb.MovePosition() to move in SmoothSyncExamplePlayerController.cs and it looks as smooth as on the owner to me.

    Using only rb.MovePosition() to move (without using SmoothSync and not even online) doesn't look that great though normally. Is this what you are seeing? Smooth Sync is copying this but it's because the owner is moving with jitter already. You can try lowering the PositionEasingSpeed to smooth it out a bit more but you're going to lose reactivity.
     
    toyhunter likes this.
  48. camirving

    camirving

    Joined:
    Jan 20, 2014
    Posts:
    34
    Hi there!

    I'm working on a co-op third person shooter.

    Imagine the following scenario:

    - Players 1, 2 and 3 are all sitting still, far away from their spawn points, not moving one inch.
    - Player 4 joins the match.

    For player 4, all the other players are at their spawn points: it's as if they hadn't moved at all since the start of the match!

    I'm guessing that players 1 to 3 aren't sending any packets because, well, since they haven't moved, there's no need to send new packets, right?

    however, player 4 needs to retrieve their current position!

    how can I fix that?
     
  49. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    429
    @camirving
    It looks like it spawns them in the correct position to me when I use the Smooth Sync Example Scene. I tried spawning with NetworkServer.Spawn() and it works too.

    Which networking API are you using? (UNet, PUN, PUN2, Mirror)

    Paste me the code you are using to spawn your object so I can see how you are spawning.
     
  50. camirving

    camirving

    Joined:
    Jan 20, 2014
    Posts:
    34
    Thanks for replying!
    I'm using Mirror.

    Here's my spawn code:


    Code (CSharp):
    1. [Command]
    2.     public void CmdRequestPawnSpawn(Vector3 pos, NetworkIdentity id)
    3.     {
    4.         GameObject pawn = Instantiate(NetworkManager.singleton.spawnPrefabs[0], pos, Quaternion.identity);
    5.  
    6.         NetworkServer.Spawn(pawn);
    7.  
    8.         NetworkIdentity ent = pawn.GetComponent<NetworkIdentity>();
    9.  
    10.         id.GetComponent<PawnController>().PawnNetId = ent.netId;
    11.  
    12.         ent.AssignClientAuthority(id.clientAuthorityOwner);
    13.     }
    My player prefab works as follows:

    The root of the player prefab does not move. The player's character is actually one of the prefab's childs.
    The root of the player prefab has a NetworkIdentity and two Smooth Syncs, just like the readme file says.