Support => TNet 3 Support => Topic started by: Rexima on April 08, 2014, 02:28:55 AM
Title: Massive Lag problems
Post by: Rexima on April 08, 2014, 02:28:55 AM
I have a huge problem with the Sync of an Rigidbody. I made everything like you said, but i cant get smooth sync.
My player prefab looks like this
Rigidbody, TNObject, sync script
- Collider 1
- Renderer
I tried it out with Interpolation = Laggy result (If i collide with a player, it takes around 1-3sec then we collide) I tried to send the Players KeyStroke to the host and the host sends it back to all player = The players on Host side, works smooth, but on the client side im lagging, because i get my own keystrokes after a few seconds back.
Im at work right now, but i later i will post my interpolation script here, so maybe i made something wrong :(
Title: Re: Massive Lag problems
Post by: ArenMook on April 08, 2014, 02:38:22 AM
Most common cause of this is flooding the network by sending packets every frame.
Title: Re: Massive Lag problems
Post by: Rexima on April 08, 2014, 03:02:28 AM
I have a tickrate of 10, this means i send every second 10 packages.
Even if i try your SyncRigidBody Script, it still laggy.
Title: Re: Massive Lag problems
Post by: djray2k on April 08, 2014, 11:42:58 AM
Are you testing it locally or across the internet? I had things running in the background when I first tested online and I didn't immediately see why my game would lag.
Title: Re: Massive Lag problems
Post by: ArenMook on April 09, 2014, 04:29:35 AM
I once had a dual band router, and when I was connecting a device from 5 Ghz to a device that was on 2.4 Ghz or vice versa I would get some epic 1.5 second lag. Aside from such edge cases though, nothing will cause lag. Especially with the built-in examples.
Title: Re: Massive Lag problems
Post by: Rexima on April 09, 2014, 10:19:25 AM
So,
in the attachments you will find my PlayerSync Script. My Settings currently are: Tick Rate: 20 Interpolation Limit: 0.1 Extrapolation Limit: 0.2 Extrapolation Time: 0.1 State Buffer Size: 10
It runs a little bit "smooth" but its not perfect.
I add to the OnNetworkJoinChannel: TNManager.noDelay = true; And to Start(): TNManager.StartUDP(Random.Range(10000, 50000));
Could someone tell me, how to improve it?
Title: Re: Massive Lag problems
Post by: djray2k on April 09, 2014, 05:08:41 PM
Just a suggestion because I don't know if this is causing the problem or not, but you're sending a float and 4 vector3's with a tickrate of 20, which in your code means it is being about once every 3 frames to every person. I think the bandwidth is being tested and some packets are being dropped.
Maybe try sending just the position to see if it's the amount of data you're sending that causing the game to lag.
Title: Re: Massive Lag problems
Post by: ArenMook on April 10, 2014, 08:17:38 AM
The fewer packets you send and more interpolation you use, the smoother everything will be. In the multi-purpose game starter kit I send data 4 times per second, and even that is too much and can be reduced. The key is to send an update when something notable occurs -- like a collision with another object, and let interpolation take care of it in the meantime.