Author Topic: Latency / Ping  (Read 1795 times)

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Latency / Ping
« on: June 12, 2016, 10:11:01 AM »
Hello ArenMook,
I am making a small prototype of an MP game with Rigidbodies(using Rigidbody autosync), i have hosted a server on my PC and the pings that i get from a PC build and Editor when using public IP is ranging from 20 to 200 ms. The experience is laggy, is there anything to keep in mind while doing it? or syncing rigidbodies is a bad idea?

I was testing it with multiple settings for data transfer from 10 - 30 times per second. Also tried marking it as important.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Latency / Ping
« Reply #1 on: June 12, 2016, 09:00:16 PM »
Generally if you are sending something more than 10 times per second, you're doing something wrong. Think about it... if you have 2 players, that becomes 20 packets per second in, 20 packets per second out. If you have 4 players, that becomes 40 packets per second in, 4*10*3=120 packets per second out (10 per player, has to be sent to other players, so 10*[playerCount-1] for each player). With 10 players that's 10*10*9=900 packets per second out. With 100 players you're at 100*10*99= 99,000 packets per second sent out. You see where I'm going with this? This is why in the car example I have a frequent input sync, and an infrequent position correction sync. In a serious game you'd also use some form of predictive logic in order to cut down on the number of packets. If controlling via a keyboard only instead of a joystick it becomes much easier as you can then sync button press states instead of input axes.

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: Latency / Ping
« Reply #2 on: June 12, 2016, 11:53:04 PM »
Thanks a lot ArenMook,
I will implement the position sync and test it out.

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: Latency / Ping
« Reply #3 on: June 13, 2016, 09:32:15 AM »
I am syncing position 5 times per second and moved the renderer to the child of rigidbody with SpringTransform script on it.
Its a lot better now, Thanks!
if i have more doubts ill get back! :)