Search Unity

Resolved Clientside prediction: How to reduce differences between client and Server?

Discussion in 'Scripting' started by M1st3rButt3r, Jan 15, 2021.

  1. M1st3rButt3r

    M1st3rButt3r

    Joined:
    Oct 22, 2020
    Posts:
    11
    I currently work on a client side prediction and it works properly also the correction works well, but I have the problem that I have sometimes a very high difference between client side prediction and the server around 0.2 to 0.4 Units. Which in my opinion is way too much my goal was an offset under 0.1 units.
    What are normal offset values? And does anyone know how to fix the prediction? Is this difference in physics normal in unity (I use a rigidbody for movement).
    Thanks for answers!
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    The absolute amount of difference to expect depends on how fast the objects are moving. But generally the idea is you take the velocity of the object multiplied by the average one-way latency of your communication with the server, and offset the object forward along its velocity by that amount.

    The actual amount of the offset is going to depend on the velocity of the object and the latency to the server, so you can't really give an absolute expected or "good" number.
     
  3. M1st3rButt3r

    M1st3rButt3r

    Joined:
    Oct 22, 2020
    Posts:
    11
    Thank you for the help, but I think I explained it missleading, its clear to me that server and client at one time don't have to same position. I calculate the difference not with the current position of the player if I get a position packet, I compare it to the past, where I sended the matching Input so I think latency shut not effect the offset (Am I right?). So there is an Invalid prediction on the client even if its got the same input. (btw your cat is very cute, my cat looks very simillar :) )