Can anyone give me some advice on technical design around accepting and processing player input? I am using Unity for the client side.
Atm I am just sending a message to the server every frame as long as a key is held down and I am just adding a value to x/y when the command arrives. Would it be better to have a short timeout between sending such messages?
private void Update()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
client.Send(Msg_MoveLeft);
}
...
movePlayer(client: Client, action: string)
{
if (action === "L")
{
this.players[client.sessionId].x -= 0.1;
}
How would one deal with movement speed server side? I was thinking I should collect the player's wanted actions like, move left, right, etc; and then in the "update" function, which is a setSimulationInterval callback, I would do the actual movement so that it is locked to some time interval (movement speed).