Hey!
I am writing a networked game using Box2D, but I have come to a point where I can't figure something out.
The situation:
The player on the client moves to the right, at this moment that is done by applying a linear impulse with delta v:
The client saves this information and sends 2 times a second (a bit extreme but it is for testing purposes) a packet to the server with all the impulses applied to the player.
The server applies all these impulses.
The problem is that the player on the server moves less far than the player on the client.
I think it has to do with the server applying all the force in one timestep while the client could have applied all the force in 30 timesteps.
Is there any way to let the server behave the same way as the client while still receiving 2 packets per second?
Thanks in advance!
I am writing a networked game using Box2D, but I have come to a point where I can't figure something out.
The situation:
The player on the client moves to the right, at this moment that is done by applying a linear impulse with delta v:
Code:
float deltavx = desiredvx - oldvx;
float impulse = body.getMass() * deltavx;
body.applyLinearImpulse(impulse);
float impulse = body.getMass() * deltavx;
body.applyLinearImpulse(impulse);
The client saves this information and sends 2 times a second (a bit extreme but it is for testing purposes) a packet to the server with all the impulses applied to the player.
The server applies all these impulses.
The problem is that the player on the server moves less far than the player on the client.
I think it has to do with the server applying all the force in one timestep while the client could have applied all the force in 30 timesteps.
Is there any way to let the server behave the same way as the client while still receiving 2 packets per second?
Thanks in advance!