Search Unity

Authoritative Controller send inputs framerate independent

Discussion in 'Multiplayer' started by Deleted User, Nov 10, 2017.

  1. Deleted User

    Deleted User

    Guest

    Greetings Unity community.
    I would like to ask an advice concerning authoritative controller and precise logic.

    What I've done that I was sending inputs in FixedUpdate(); putting them into Queue<> on the server and then processing them with the same time stamp so I've got such a good movement sync. But then I've figured out that FixedUpdate(); is really frame dependent so if the client has more fps than VSync it leads to asynchronization between server and the client the same happens if client is struggle with framerate.

    So what I would like to do, ss to make a precise command sending framerate independent so that means: No Coroutines from the main thread, no Invokes, but maybe a new Thread which would send inputs let's say every 20ms not less, no more. I would appreciate any help, thanks.
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    You can use Time in Update (if elapsedTime > ...) or InvokeRepeating("SomeFunction", someInterval).
    Using threads is no guarantee that your function is called every 20ms either. If your computer is under heavy load then even the thread might only be called every 30ms sometimes.
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    I think my problem occurs because of the Input System which is frame dependent.