Author Topic: Massive Lag problems  (Read 2810 times)

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Massive Lag problems
« 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

  1. Rigidbody, TNObject, sync script
  2. - Collider 1
  3. - Renderer
  4.  

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 :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Massive Lag problems
« Reply #1 on: April 08, 2014, 02:38:22 AM »
Most common cause of this is flooding the network by sending packets every frame.

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Re: Massive Lag problems
« Reply #2 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.

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Massive Lag problems
« Reply #3 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Massive Lag problems
« Reply #4 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.

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
Re: Massive Lag problems
« Reply #5 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?
« Last Edit: April 09, 2014, 12:59:04 PM by Rexima »

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Massive Lag problems
« Reply #6 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.

  1. ...
  2. tno.SendQuickly((int)RFCConstants.SyncCar, Target.Others, state.TimeStamp, state.Position, state.Rotation, state.Velocity, state.AngularVelocity);
  3. ...

Maybe try sending just the position to see if it's the amount of data you're sending that causing the game to lag.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Massive Lag problems
« Reply #7 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.