Search Unity

Feedback Issue with lag compensation accuracy

Discussion in 'NetCode for ECS' started by EugenyN1, Sep 13, 2022.

  1. EugenyN1


    Jun 21, 2019
    I looked at the LagCompensation example in more detail and noticed that in about 1 in 10 cases the result of a hit on the client and server does not match.


    I doubled the speed of the cube and added visualization of colliders at the hit moment on the client and server:
    Code (CSharp):
    1. var color = isServer ? Color.cyan : Color.yellow;
    2. Debug.DrawLine(rayInput.Start, rayInput.End, color, 5);
    4. if (hit)
    5. {
    6.    DebugExtension.DebugCircle(closestHit.Position, math.up(), color, 0.05, 5);
    7.    var index = collWorld.GetRigidBodyIndex(closestHit.Entity);
    8.    var body = collWorld.Bodies[index];
    9.    DebugExtension.DebugLocalCube(new float4x4(body.WorldFromBody),
    10.        new Vector3(1.0f, 1.0f, 1.0f), color, default, 5);
    11. }
    and saw that sometimes the colliders do not match:


    then I found out that it depends on the FPS value. If we force 15 FPS (Application.targetFrameRate = 15) then we will see a large divergence of colliders:


    It seems that the lag compensation does not work accurately and the hit check is highly dependent on FPS.