libgdxkryonet

Issue with delta time server-side


How can I make server-side game run the same on every machine, because when I use server's delta time it works different on every computer/phone.

Would something called 'fixed timestep' help me ?


Solution

  • Yes fixed timestep can help you. But also simple movement with a delta can help you. Fixed timestep commonly using with a physics because sometimes physics needs to be update more often (120-200hz)than game's render method.

    However you can still use fixed timestep without physic. You just need to interpolate your game objects with

    lerp(oldValue, newValue, accumulator / timestep);
    

    In your case probably small frame rate differences causes unexpected results.

    To avoid that you should use movement depends delta.

    player.x+=5*60*delta;//I assume your game is 60 fps
    

    Instead of

    player.x+=5;
    

    So last delta will be only difference between machines.And its negligible since delta difference between 60 and 58 fps is only ~0.0005 secs