- Home /
UNET Network Transform Component lags
I'm using the Unity 5.1.1 UNET network transform component for a multiplayer game. Movement is done by using the rigidbody2d component. However, even on clients running locally (=connected to "localhost") there is way too much lag between server and client.
You can use the following demonstration project for unity to reproduce my problem. Box2D Network Transform Demo Project
Simply open the ControlBox2D.unity file in the Unity editor. Build the scene twice, start one as host and one as client. On the client window, press "s" to make your coinbox jump. On the host, press "s" to make your coinbox jump together with the client's coinbox on top of it. Notice the input lag on the client side.
The jump is done by adding a force to the object's rigidbody2d.
On the Cube2D prefab (it's located in "Assets/Scenes") you can check the settings of the Network Transform Component. It is set to sync it's Rigidbody2D. Using syncmode "transform" would produce very jittered movements. Next, check the Network Identity Component. It is not set to "local player authoraty", as this would not allow the coinbox below to jump. The coinbox above it would refuse to move it's position if set to "local player authority".
Now on the Cube2D prefab, activate the option "Client Side Prediction". This should reduce input lag on the client by adding the force on the server and on the client. However, all I'm experiencing is jittered movement.
For testing purposes, I deactivated the network transform component and activated the option "ClientSidePrediction". This way, I bypassed the network transform component and only relied on rigidbody actions being correctly sent over the "network". Due to scripting, it only works when pressing jump on the client! Interestingly, I cannot observe any input lag neither on the server nor on the client and the movement is completely smooth.
So my questions are:
Why does the Unity Network manual recommend to use "local player authority" when it obviously breaks the physics system for all clients?
Why does the UNET network transform component introduce that much lagging by default even when connected through localhost?
What is the best workflow for making the rigidbodies sync smoothly in multiplayer games without adding any artificial latency on top of the internet latency? Should I avoid the UNET network transform component for a multiplayer game with physics based movement or am I using it the wrong way?
Did you ever figure this out? In my project it's smooth for me on the host but on the client it lags behind a lot.
Yeah I too would love an answer on this. I'm curious if I'm doing something wrong or if UNet might just be slightly limited at the moment
Why hasn't this been answered? I just got 5.2 and the network transform is even worse that it was before. I am able to set the send rate to 0 for the player and it is smooth as butter. However when this is done on an enemy object the enemy doesn't move at all. Setting it to 29 seems somehow much faster and smoother than setting it to 1. This makes no sense what so ever to me. I really need some help here.
Why wouldn't it be smoother when you set it to 29 vs 1? It is how many updates to send per second. So 29 updates per second will be faster and smoother than 1 update per second.
Answer by ODINKONG · Oct 15, 2015 at 04:14 AM
ok I seem to get a pretty good sync if I set the send rate to 29 and make the snap very high while keeping the movement threshold and the interpolation low. However it still seems very in accurate in intense quick combat situations.
It doesn't look bad as it was before or I just got used to it :D
Answer by zfscgy · Jun 21, 2017 at 03:49 AM
If only using the command functions to sync, sometime server and client will accumulate very small offsets to a very big one, especially when the game is large and need a lot of physics...