Netcodes Network fast placed game – need better direction

  javascript, networking, tcp

Hello dear developers.

I started to work on fast placed online game (some sort of 2D MOBA). I encounter a problem with netcodes.

My netcodes are using those techniques:

  • Clientside Prediction & Server reconciliation
    • (Server is sending position and player is replaying unprocessed inputs)
    • (Player is sending input each frame (60 times per sec) which are processed on serverside)

Other entities are interpolated
Bullets/Abilites are extrapolated (Dead-reckoning)

  • This is working good sofar

The main problem here is that abilites are processed on server first (I need to do it this way). So if player press ability which dash him in front, server needs to process this input, dash the player and then send to player that player should dash (it is not predicted on client) – There is a problem, because my player is teleported back for a couple frames at the end of dash.

Example: Player sends K (Dash request) at 0ms, it arrives on server at 50ms. Server process it and set player into dash (Forced movement) which takes 400ms. Player receive that he is forced to move (Dash) at 100ms (#1 problem is that, if player pressed dash he still moved this 100ms if he holds D, but on serverside he is dashing so those Ds(right move) were ignored), #2 problem. Dash ends on server at 450ms, but on client at 500ms (if connection is stable) so client will tp back for those 50ms

Why i can not apply client prediction for dash? Simply because you could be dashed from projectiles or enemy abilites, which can be predicted / like Slow/stun/charm (I call it forced movement).

Is there any idea how to handle those forced movements or stuns/slows without teleporting player for some frames ?

What is the best idea how to handle it?

Source: Ask Javascript Questions