I created the authoritative server controls like in the tutorial, and everything worked fine until I modified it to my game, which is grid based, so the movement in one frame is with a fixed distance to another tile.
Everything works well on the server, but on the client, the player moves many tiles too far and then gets reset to the correct position by server. It worked properly on continuous movement because it was hard to spot (the player moved a little faster than he should, that is it).
Upon further investigation the problem is with ExecuteCommand() run on the clients PlayerController.cs, it takes place 4-8 times in consecutive frames for a single run of SimulateController() with actual input.
So in PollKeys() I actually track only Input.GetKeyUp (so it is only true in one frame), PollKeys() in SimulateController() is run only once, SimulateController() is run only once, and I get 4 to 8 consecutive ExecuteCommand() calls on the client (so not in single frame, one frame after another).
What can I be doing wrong? Thank you in advance for any help.
Everything works well on the server, but on the client, the player moves many tiles too far and then gets reset to the correct position by server. It worked properly on continuous movement because it was hard to spot (the player moved a little faster than he should, that is it).
Upon further investigation the problem is with ExecuteCommand() run on the clients PlayerController.cs, it takes place 4-8 times in consecutive frames for a single run of SimulateController() with actual input.
So in PollKeys() I actually track only Input.GetKeyUp (so it is only true in one frame), PollKeys() in SimulateController() is run only once, SimulateController() is run only once, and I get 4 to 8 consecutive ExecuteCommand() calls on the client (so not in single frame, one frame after another).
What can I be doing wrong? Thank you in advance for any help.