Search Unity

Question Problem with netcode client stuttering

Discussion in 'General Discussion' started by elzbeb, Nov 17, 2022.

  1. elzbeb

    elzbeb

    Joined:
    Jul 30, 2020
    Posts:
    54
    Hey so I am working with a simple multiplayer setup here but the issue is when I build and run the project, the host is lagging on the client's side and vice versa, notice when I press ctrl + esc, the player teleports to where they should be https://imgur.com/a/cumenLW.
    Here is another view but from the editor this time, so if I am the host in unity I don't lag in the build, but I lag if I am the client https://imgur.com/a/b4oSk7q.

    What could be causing this issue?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    Hard to say. What codebase for the character controllers are you working with?

    The first video almost seems like the background instance of the build simply has a lowered update rate because it is not running in the foreground. This could be due to some Player settings.

    You may want to install ParrelSync so you can test with two and more editor instances running the same project (the cloned projects are read-only so there won't be any conflicts).
     
    Noisecrime likes this.
  3. elzbeb

    elzbeb

    Joined:
    Jul 30, 2020
    Posts:
    54
    Well, I am using netcode on the third person controller asset provided by unity, now here is the thing, when I change the player model to a capsule there is a significant change in the stuttering I would even say that it's almost gone, you can look at the video and judge it yourself, what do you think the issue might be? It's not the movement script and I don't think it's coming from netcode itself but rather from the player model, also here is a screenshot of the warning that unity prints when I move the client
    photo_2022-11-18_17-41-05.jpg
    https://imgur.com/a/6GMFdDR
     
  4. elzbeb

    elzbeb

    Joined:
    Jul 30, 2020
    Posts:
    54
    Kk so I think I boiled it down to the main thing,
    when tabbed in unity, the game runs at 300fps when I tab out its at 15 here is a video https://imgur.com/a/uboxKx6
     
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    Like I said before, the background app may be tuning down its processing because it's in the background. I believe there is some flag in the Player settings. I have not observed this on my computer.

    Also: use ParrelSync, that should avoid this problem altogether and makes testing a lot faster than having to make frequent builds.