Author Topic: lag in car movement demo  (Read 2372 times)

rik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
lag in car movement demo
« on: January 29, 2017, 02:01:07 PM »
Hi i have tested the car movement demo on mobile but i have noticed some lag where player will be moving and all of a sudden it will move to the current position.

i am hosting server locally so i am not sure what might be reason.

did some experience same problem ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lag in car movement demo
« Reply #1 on: January 30, 2017, 07:30:06 AM »
Did you play with the sliders, adjusting the update frequency rates? Often mobiles batch smaller packets by default into larger chunks that are sent less frequently, which results in updates arriving 2-4 times per second instead of the expected 10-20. This can be forced off via TNManager.noDelay = true.

From what I recall in the demo scene input is sent frequently, and position/rotation correction packets are sent infrequently. When there is a big discrepancy between the current and arriving position, the vehicle will "snap" to target.

rik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: lag in car movement demo
« Reply #2 on: January 30, 2017, 01:05:34 PM »
i have tried increasing the update per second it made it better but i can see some lag now and then.
i am trying to compress the position and rotation values so there will be 60% less traffic over network.
but i am not sure how to do the compression part but i can give an example.
ex:car position is vector 3 (20.02111,2.01222,200.0001);

i want to compress that to vector 3 ( 20.02,2.01,200.00);
can you make a helper function to automate this stuff.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lag in car movement demo
« Reply #3 on: February 04, 2017, 03:57:42 AM »
Uh... when you print, you see a string. When the value is sent over the network, it's sent as floats. A Vector3 is sent as 3 float values (12 bytes), and whether it's printed as (0, 0, 0) or (0.123456, 0.123456, 0.123456) it still takes the same amount of bytes as floats. There is nothing to compress there. If you want to reduce bandwidth, you could simply send less data, or send it less frequently. For example you could only send X and Z position instead of XYZ.