Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved What are the proper values for latency, jittering and packet loss simulation?

Discussion in 'Netcode for GameObjects' started by JamesW940516, Oct 9, 2023.

  1. JamesW940516

    JamesW940516

    Joined:
    May 19, 2023
    Posts:
    31
    Hello

    I have created simple Multiplayer game with Unity Netcode for GameObjects.


    While making the game, I focused on the optimization, performance and responsibility of sever and game network system.
    A problem came out when I simulate the latency, jittering and packet loss.
    There are two videos here.
    Actions and movements are smooth in the first video. On the contrast, the actios and movements are not smooth in the second video.
    I set the latency = 10 jittering = 10 and packet loss = 1 in second video.
    upload_2023-10-8_22-40-55.png
    These two videos are about local network test.

    So I have some questions now.

    #1. If I want to create this game for good network situation clients, what are the proper values for Latency, Jittering and Packet loss of Simulation? I want to make smooth my game in that simmulation.
    I know the values are different each other in different situation. What I am saying about is the values of client which is good for online games.

    #2. Only some clients are in bad network situation (high latency jittering and packet loss) in my point of view.(The reasons are long distance from server, network communication quality of a bad client...) I want to detect these bad clients and kick them out from my multiplayer system.
    How can I detect them and let them leave from my server?

    Thank you in advance for your advice.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,659
    1. Is easy. Good conditions means there is practically no packet loss, so set drop rate to zero. Delay (latency) is what you can reasonably expect for a player in your game. I would go for 50ms with 10 ms jitter for a desktop game. Double the numbers for mobile.

    2. You wouldn‘t kick them! That would be rude! You do warn them though, like with the common turtle or hourglass icon to inform and possibly deter them from playing on this server. The only measurement you need for this is latency because jitter is irrelevant, it will come up as fluctuating latency. And packet loss naturally increases latency. Define a reasonable minimum ping for your game such as 250 ms and show the turtle icon when the connection is above the threshold, on average, for the past 1-2 seconds. You may also show another icon if latency is significantly above threshold for even short bursts to account for high packet loss happening only infrequently and shortlived.

    Some games also print ping values in green, yellow, red depending on thresholds determined for the game. Fast paced action games require pings of less than 150 but for less intense games 2-3 times that may still be acceptable.
     
    Last edited: Oct 9, 2023
    JamesW940516 likes this.
  3. JamesW940516

    JamesW940516

    Joined:
    May 19, 2023
    Posts:
    31
    Thank you very much for your quick and clear advice.
    That's really awesome and what I wanted exactly.
     
    CodeSmile likes this.
  4. JamesW940516

    JamesW940516

    Joined:
    May 19, 2023
    Posts:
    31
    Hello @CodeSmile
    I saw a weird effect simulating the latency.
    The FPS value on client went to 1040 fps when I set latency 50ms.
    I checked the Quality Setting and Timeline.
    Quality Level = Very low (for windows build and for other build targets)
    Timeline / Default fps = 60 fps
    Is this normal? I turned on the development build for network simulation
    upload_2023-10-9_6-51-23.png
     
  5. JamesW940516

    JamesW940516

    Joined:
    May 19, 2023
    Posts:
    31
    When I added this, the problem vanished
    Code (CSharp):
    1. Application.targetFrameRate = 60;