A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by Fuestrine, Aug 4, 2017.
I got 28 errors?
I am trying to get my player to sync across the network using only the velocity only with 2drigidbody. But it is not working am not sure what I am doing wrong. Any advise would be tremendous. Below is an example of my project.
(note: am able to get it to work with transform)
(note: I was able to add PhotonRigidbody2DView on character and as an observed Componet. But I thought this was wrong I felt PUN2 should be able to do this without having to add that componet.)
- Creating 3 pre-configured Character's on master across network
- Having all characters do some action (jump)
- Each Character has a different type of network syncing for us to compare each syncing type. (our old net code sync transform, pun2 transform sync, pun2 velocity sync )
Componets on Character GameObject
Hi there, great product so far! I just encountered a special situation for me:
I've got a vehicle, in which players can step (they'll become a child of the vehicle, so that they can move inside the vehicle with local movement), and once they step out of it, they become a child of another gameobject (let's say "World").
How to achieve that with smoothsync? Both possible parents (vehicle and world) do have the smoothsync-script attached to it. Do i have to add a component, once the player is attached to a new parent or will smoothsync handle that for me, as long as the player has a smoothsync component attached?
I've stripped down my parenting manager to the bare minimum, maybe you can tell me, how to set that up correctly:
public class PlayerParentingManager : NetworkBehaviour
private bool _isInVehicle;
private Transform _playersOutOfVehicleParent;
private Transform _playersInVehicleParent;
_playersOutOfVehicleParent = GameObject.Find("World").transform.Find("PlayersOutside").transform;
var collisions = Physics.OverlapSphere(transform.position, 0.5f, LayerMask.GetMask("VehicleCollider"));
if (!collisions.Any() && (_isInVehicle || transform.parent == null))
_isInVehicle = false;
if (collisions.Any() && (!_isInVehicle || transform.parent == null))
_isInVehicle = true;
So - do players even have to have a smoothSync-Script attached, or only the PlayersOutside and PlayersInside gameobjects with a second one ChildObjectToSync set to the player?
Specifically asking - do i have to do the parenting on my own on every client by sending a message to them that the parent changed, or will smoothsync take care of that?
If i have a nested set of Gameobjects, of which i want to sync layer A and C:
How to set smoothsync up correctly?
Adding SmoothSync-Component to A twice (one with none as ChildObjectToSync and another one pointing to B) and then adding one SmoothSync Component to B with ChildObjectToSync set to C?
or adding three of them to Component A (one with none as ChildObjectToSync, one pointing to B and one pointing to C)?
Or only adding two to A (one with none as ChildObjectToSync and another one pointing to C directly)?
Thanks for your reply in advance - looking forward!
Is there going to be a fix for the latest version of Mirror?
I'm seeing ~35 errors due to changes to NetworkWriter for Mirror.
Hey, I already replied to you in email but wanted to reply here too so people don't think I'm ignoring you.
You will have to change the parent on every networked instance of that object. Smooth Sync should handle it from there. Worst case scenario is you may have to call SmoothSync.Awake on each SmoothSync on the object you are changing the parents/children of.
For the A, B, C:
Check out the provided Smooth Sync Mirror Example scene for a similar scenario.
But if you want to sync just A and C. Put two Smooth Syncs on A and hook one of them up to C using the ChildObjectToSync public variable.
It works for me with the latest version of Mirror on the Asset Store.
Unfortunately I can't support each minor change they release on the Mirror github. Let me know if the Asset Store version doesn't work though, those are the major releases that I try to stay compatible with. Thanks for letting me know that a newer version will break it though, I'll also try to keep an eye out for it.
What networking system are you using?
When do the errors appear?
I don't think I've ever had someone try to sync only velocity before.
Smooth Sync currently doesn't have this functionality.
If you sync using only velocity, it will be very inaccurate and would only be useful in specific scenarios.
One reason is that velocity is going to be different between send rates so it's going to not be able to stay at about the same position that well and it will only get more and more off as the game goes on.
Also, if you get bumped or stopped by something (or stop getting sent velocities because of network lag) it'll just use the newest velocity sent even if it's been a few seconds of that player moving. So having your speed be 50, but being 1 second in the past, the positions are going to be pretty far off.
Basically, I'd think about syncing position. Let me know if I misunderstood the issue or if you have any other questions.
ah okay thank you very much. Appreciate the quick & detailed response.
@Fuestrine Thanks for your reply, and aswell thanks for your emails. Good idea to keep writing here to solve issue aswell for others (if they do face it).
Unfortunatelly, i still dont get the idea what exactly to do. Just changing the parent does not work, tried it aswell by extending the demo scene.
Steps to reproduce:
Add a 3D called "MovingPlatform" , scale it to 40 / 1 / 40 and move a bit down (so that you can see the parent being moved) and add the attached PlatformMover.cs script to it.
Add an empty gameobject called "IdlePlatform".
Add to both a NetworkIdentity and a SmoothSync script (leave ChildObjectToSync) empty.
Add the ParentingManager.cs script to the player prefab SmoothSyncMirrorPlayerPrefab.prefab
Press M to parent to moving platform, press I to parent to idle platform.
Once a client hops in, the scales go crazy, so do the positions:
According to the documentation, just changing the parent is wrong, as i'd assume to only have the smooth sync script attached to the top most root element, changing itself and the children.
I've tried it aswell to add / remove the smooth sync script on every parent change on every client, but this fails asell positioning the objects accordingly. Script to add / remove the smooth sync scripts:
if (transform.parent != null)
// iterate through all current smooth sync scripts, and remove us from the objects to be synced.
var currentSyncComponents = transform.parent.GetComponents<SmoothSyncMirror>();
foreach (var smoothSyncMirror in currentSyncComponents)
if (this.gameObject == smoothSyncMirror.childObjectToSync)
var smoothSync = newParent.AddComponent<SmoothSyncMirror>();
smoothSync.childObjectToSync = this.gameObject;
smoothSync.enabled = true;
newParent.GetComponents<SmoothSyncMirror>().First(x => x.childObjectToSync == null).Awake();
What am i missing of the concept of smooth sync here?
I'm getting some Mirror error with ParentingManager.cs. I'm not too experienced with Mirror these days so I'm not sure if some setup needs to be done.
How about instead, can you upload the project with that example scene you described to dropbox or something and send me the link to it in an email?
Then I'll get a perfect view as to what's happening.
Thanks for your reply, i've mailed you an example with two different approaches. I was able to get rid of the weird stretching shown in the images, just for all others that are reading this here aswell. It wasn't a bug in smooth sync, rather than a behaviour of unity when reparenting to objects with a scale other than Vector3.one.
Is it normal when using Pun2 for your first movement to be jittery? After moving then things are smooth but the very first movement input are jerky. As though smooth sync engines are starting up. Any help?
Just joined the Discord...
THIS PROJECT IS DEAD.
DO NOT BUY ...
Oh no... @Erdal42 what to do?
What a name you have!
Yes, it is normal. In the first second of movement, it is getting used to your relative ping so that it can be as good as possible as soon as possible.
I tried making it shorter but people were reporting issues. You can change line 2041 in SmoothSyncPun2.cs
if (receivedStatesCounter < PhotonNetwork.SerializationRate ||
if (receivedStatesCounter < PhotonNetwork.SerializationRate / 2.0f ||
or divide by a larger number to make this time period even smaller if you want to try it out.
In the future, I want to make it so this happens regardless of moving and it just sends for one second when the game is joined so that it is less noticeable but I haven't had time for it yet.
Let me know if you have any questions.
We are up to date on all replies here and it's only been two days since the latest post needing a reply here. This project isn't dead. I am sorry that we haven't been on discord in some weeks though so I understand how you feel. If it happens again, please feel free to poke us again by email or forums.
It's been a few months now and I haven't seen a new release.
Any idea when this functionality will be released?
Sorry about that, I was trying to release another fix at the same time and then the whole release fell to the side. I'll move this to a high priority and get it out quickly.
That would be great.
Thanks a lot.
Just submitted it to the Asset Store so I'd expect it in a few days. I'll let you know when it's out.
where is the change logs ?
Version 3.26 is now on the Asset Store.
Updated to work with latest Mirror release.
Performance improvements for Mirror.
Added server authority support via Transform Source option.
Change log posted above.
Smooth Sync Mirror that works with latest version of Mirror on the Asset Store is now out. Sorry about the wait.
Hi, is there any chance this asset works (or could be easily converted to work) with Normcore? I recently switched from Photon and would like to make sure before purchasing. https://normcore.io/
Smooth Sync would not automatically work out of the box with anything other than the supported networking systems.
I don't know anything about Normcore but if it can send a byte array across the network and you are an experienced coder, I would think the Photon version of Smooth Sync wouldn't be too crazy to convert to Normcore. But I can't really recommend it as I don't know how difficult it would be. Knowing Photon networking basics would help. Smooth Sync wasn't really made with universality in mind, it was made to be plug and play with the most popular networking systems.
Can you give a recommended setting for a game like this.
Game is top down, and players can move in any direction and also jump. Variables to sync is x,y,z of position and y of rotation. What would be your recommended Interpolation Back Time, etc and Extrapolation, Thresholds if any. Here's mine currently but I can see other moving players look like they're teleporting/glitching to where they should be running.
This is a great asset but apart from just trying every single combination of values I really wish there was some more guidance of settings. I am working at a serialisation rate of 5x /s (is that going to be too low for a fairly slow moving boat?) and i'm getting some hiccups. I believe I should set the interpolation back time as longer than than this so > than 0.2s ? Also - another specific question - how should the rigidbody interpolation be set up?
Probably too broad of a question. It all depends on what you are trying to achieve. I'd just start with the default settings. If it's not teleporting/glitching with the default settings, then slowly change the others.
One big thing to keep in mind is keeping InterpolationBackTime > 1/SendRate (serialization rate in photon land?) or you'll be extrapolating all the time which will cause weirdness.
Extrapolation and thresholds should probably just remain at default as they won't affect much.
InterpolationBackTime should be kept greater than 1/SendRate (pretty sure this is called serialization rate in photon land?). So I'd try increasing it to .3 just to test if that's causing the hiccups or not.
I don't think 5 sends a second would be too low, it all depends though on what kind of accuracy you are looking for though.
I've attempted a guide in the past but it has just ended up with me writing out all the comments that come when you mouse over the variables anyway. I'll think about it again though and see if I can approach it a different way.
I'd say just start by looking at the variables before the first drop down and ignore the rest for now. Default on all of those (except InterpolationBackTime because of your lower send rate) should be good though.
What settings are you talking about here? Really you can't go too wrong with the default settings if you have a rigidbody you are trying to sync. (except change the InterpolationBackTime to match your send rate).
Thanks for your answers. The issue is that using Update it seems to have 'surges' and using FixedUpdate it seems to stutter looking like its only updating 10x/s . I have moved InterpolationBackTime to .3 and 0.4 and also reduced the lerp speed. I have also tried various options with using velocity or not. Is it right to use velocity AND position?
The boat also has buoyancy added locally and this seems to make things worse (although if I remove it its still not 100% smooth.)
If you are changing the position locally, that'd add to the stuttering as Smooth Sync is probably trying to set the position at the same time that you are trying to set the position.
Make sure you are only setting the position on owners (and Smooth Sync will handle setting the position on non-owners) (unless of course you aren't syncing Z position or something then you would be free to set the Z position on every networked instance of the object).
If you confirm that only Smooth Sync is setting the position (and I'd probably just set WhenToUpdateTransform to Update as that's smoother) and it's still jittery, screenshot me your Smooth Sync settings and your Photon serialization rate and I'll take a look and see if I can find what's going wrong. OR if it's easy for you to send me your project, that's probably the best way for me to get a look at what might be going wrong.
Using this for movement:
// Update is called once per frame
if (MultiplayerManager.Instance.checkIfObjectIsMine(this.gameObject) && GetComponent<PlayerController>())
thisTransform.Translate(Vector3.forward * Time.deltaTime * speed * speedMultiplier);
//GetComponent<Rigidbody>().MovePosition(thisTransform.position + thisTransform.forward * Time.fixedDeltaTime * speed * speedMultiplier);
//GetComponent<Rigidbody>().AddRelativeForce(thisTransform.forward * speed * speedMultiplier);
Speed Boost code (dunno if it affects anything in sync ?)
internal void speedBoost()
this.speedMultiplier = this.speedMultiplier * 1.3f; //Change back to 1 after boost
//Set engine sound pitch
engineAudioSource.pitch = engineAudioSource.pitch + ((speed * speedMultiplier) / 10);
internal void speedBoostReset()
this.speedMultiplier = this.speedMultiplier / 1.3f; //Change back to 1 after boost
//Set engine sound pitch
engineAudioSource.pitch = engineAudioSource.pitch - ((speed * speedMultiplier) / 10);
Yet the result
I do not get why I am having this kind of result I have been trying to solve this mystery since a week now tried pun transform view, classic view, self ccreated lag correction and compensation solutions via punobservable, PUN Simple Network Sync yet everything similar problem where even if I bring one car close to another in 1 window, its still away from it in 2nd window
Detailed code/problem thread - https://forum.unity.com/threads/photon-pun2-non-rigidbody-lag-compensation-and-jittery-cars.912779/
I have also PMed you my project zip file to take a better look if you want to as I am now just clueless as a duck
Hi. I responded to you on discord already but I'm going to copy/paste my response here so others can see too. Let me know if you have more questions.
So depending on your speed, things are just never going to line up perfectly. Check out a game like Fortnite and run next to someone and look at the two screens. It doesn't line up.
You'll also see some jitter too. It's hard to notice in a real game and barely affects gameplay but even Fortnite has these issues. Most of networking is just hiding the fact that there's a limitation on how accurate two computers can be because of network lag.(edited)
Even two instances of your game on the same computer, you have to tell it to send position, wait a frame for it to actually send, receive it on another frame, then apply it on the next frame. (Maybe one less frame, I forget the exact steps) I forget the math right now, but at like 60mph, you are still going to be "meters" (units) apart.(edited)
You'd have to be constantly extrapolating into the future for it to line up, which then produces a whole host of other issues.
As far as using Smooth Sync to line up better, try lowing InterpolationBackTime but try to keep it over 1/send rate(send rate is serialization rate in photon land?) or else you will be extrapolating a lot which may cause jitter.(edited)
InterpolationBackTime specifically puts objects that amount of time in the past to buffer against lag spikes. So you could lag out for .1 seconds (the default InterpolationBackTime value) and still have buttery smooth super acurate representation of where the other player went.(edited)
One thing I implemented for cars and following jitter in Smooth Sync is "Use Velocity Driven Syncing" under the Miscellaneous section of Smooth Sync settings. This will make it smoother, but it WILL be less accurate. Everything in networking is a trade off and it's just never going to be perfect because of the asynchronous limitations of networking.
Hi there, I was wondering how well this asset would sync an entire ragdoll (All of its limbs individually). Would that work well?
I am using an active ragdoll system so I can't just sync animations - but if I disable the animator on all non-owners and just have the owner sync all bone transforms, could that work?
I would think syncing each limb individually would be a waste of networking resources. Depending on how important it is to your game, I would just sync the parent and let the limbs flop around.
But if it's important to sync each limb in your game, I don't see why Smooth Sync wouldn't be able to sync your limbs. I just worry you are trying to sync hundreds of objects which no networking would handle that well. It's not a Smooth Sync limitation though, just a limitation of whatever networking system you are using. In fact I would think Smooth Sync would help with syncing them better because we offer a lot of ways to reduce the networking resources that are used for transformation syncing while still remaining buttery smooth.
Let me know if you have any questions.
Thanks a lot, I'll buy it!
What does Smooth Sync do? I just bought it thinking maybe it'll make my multiplayer easier to deal with. Does it sync my objects for me without me having to code it in? Can it also Sync animations if so? I haven't tried it yet but I'm getting ready to.
Yes, just place a Smooth Sync onto your object and if it's a networked object, it will automatically sync transform (position, rotation, etc.) without you having to code anything.
I don't know much about animations but if it's an object with a transform, it'll sync that. So if your animation is just moving objects with transforms, it should work for that.
Let me know if you have any questions.
Would this allow me to turn a game into a multiplayer game with no coding required? and if so what is the limit of players
No this would not. You would still have to do a bunch of spawning code, game logic code, connection code, etc.
Smooth Sync sends Transforms (position,rotation,etc.) and receives Transforms and makes it Smooth on every connected system.
Hi @Fuestrine !
SmoothSync works great for me, except the first second or so for any object. There's a visible jitter, as you can see on the Dragunov I'm dropping here:
This happens for EVERY object in the first second of synchronization (the weapon isn't synchronized before it gets dropped - so SmoothSync starts syncing when it is dropped).
After this initial jittery sync it's fine. (you can see me dropping the gun a second time and it is smooth)
This happens regardless of settings (interpolation, extrapolation, smoothing). Nothing helps.
Can someone help?
You are correct, this does happen for one second of movement after spawning.
You can change line
if (receivedStatesCounter < sendRate ||
if (receivedStatesCounter < sendRate / 2 ||
or even a larger number than 2 if you want this for less time. (or you may be able to just comment out that first OR of the conditional all together? It may not even be needed this days now that I think about it)
It was initially in there to get used to the average ping. When I put that lower, people were saying they had issues so I put it back to one second, but you can probably lower or maybe even take it out. I eventually want to make it so it's the first second after spawning and not the first second of movement but haven't had time.
On a sort of side note but still related, you probably will want to make pools of objects that you just move into place instead of spawning them at runtime. This will get rid of CPU lag spikes at least a bit, but it depends on how much you are spawning for if it's even worth it to go down that dark road.
Let me know how it goes.
Thanks that fixed it I'll report back if there are any issues because of this change.
@Fuestrine another issue which might or might not be related to SmoothSync. Although it seems to me its a smoothing/timing/interpolation issue.
The player positions get desynchronized. You can see where they should be (bullet starting position) and where they appear. This happens only after the server has been running for several hours. Usually about 12-24 hours (not sure exactly). Is this a timing/interpolation issue?
The reason I think this is SmoothSync is that you can see the player aiming and shooting correctly (synchronized). Aiming/shooting are done with my own code. The only thing out of sync is the player position which is handled by SS.
Soldat remake?! Did you see they are making a number two? One was/is such a great game.
Anywho, there is an issue after running the game for 40+ hours or so due to floating point imprecision at higher numbers, but that's more of a jitter and less of a desync I would think. I have a fix for that but I haven't released it yet. I wouldn't expect the issue after 12 hours or so though anyway, but maybe. I can email it to you if you want to check it out. It basically resets the game time every 36 hours.
Maybe keep this same idea in mind for your own code, floating point numbers just become inaccurate at higher numbers, I personally chose 131072 as my highest number but I stayed on the safer side. Unity variables don't have this built in so keep that in mind when using things like Time.RealTimeSinceStartup.
There's also just the standard that Smooth Sync puts things SmoothSync.InterpolationBackTime amount of time in the past on purpose to cover up lag spikes. I don't think this is the main issue though as this doesn't happen at lower amounts of time that the game has been happening.
Maybe in the same vein of this, if this issue is easily repeatable, try increasing TimeCorrectionSpeed and see if the issue still persists. It WILL jitter at higher values pretty quickly but keep going and see if you get the descyn after 12-24 hours.
So two things to possibly try on your end:
1. I have a fix if you think it's because Time.RealTimeSinceStartup is going too large and becoming imprecise. PM me your email or email me at the support address.
2. Try increasing TimeCorrectionSpeed by a decent amount (I'd say crank it to like 3.0 to make sure) and see if the issue persists and it'll help me track down the issue.
Let me know how it goes.
Hey there Fuestrine! Ok this may have been answered but what should I do in this situation? When one of my players die and respawns, his dead body is like teleported and to his respawn spot. How do I stop it from following his body to his new spawn location? So basically its syncing the body while its respawning instead of just disappearing like it should then reappearing at the spawn location
I'm making a VR demo with SteamVR controlling the hands and mirror managing the networking. With mirror the players and items are synchronized but I'm having an issue that when the items are picked up they become parented to the SteamVR hand and the items visibility disappears from the clients that aren't holding the object. Each player can push the object about and other players can see the movement but when the object is picked up it disappears from others view until its dropped again. Would Smooth Sync fix this right out of the box with the way it handles rigidbodys or do you suppose it will take some coding?