Freezing a character controller/body for individual updates
Posted: Sun Mar 31, 2013 3:06 pm
Hi,
So I am implementing a client server networked fps and my solution for client side prediction involves freezing all other players while processing the current input on the server. I have it working so that players will not move during an update if I take these steps:
1. make entity kinematic
2. set entity velocities to 0
3. space update
4. make entity dynamic (uses saved local inverse inertia)
5. set velocities back to pre-freeze
However, I now need to implement objects on the server which can move the players during updates when there is no input, so simply freezing the player to update the space will no longer work. Using an elevator as an example, when the elevator updates but the characters body is kinematic, it will not be pushed up by the elevator but will instead begin to fall through it.
I thought a solution that would be simple given my current implementation would be to eliminate the kinematic and dynamic part, so that elevators can still move the object but the controller input should not be applied until required. If I do this however, the entity still moves
1. set entity linear velocity, rotational velocity to 0
2. space update
3. set velocity back to pre-freeze velocity
As well as this, I check in my CharacterController's IBeforeSolverUpdateable.Update(float dt) method whether or not the character should be frozen and this method does not get updated when it shouldn't. So my question is what could be causing an entity with a character controller attached to be moving, when I set the velocity to 0? Are there other updateables in the character controller code which need to be disabled for these updates? When the character is on normal ground I would like the update to happen as if the character was kinematic, but it still needs to be pushed by certain dynamic objects such as elevators.
PS. Is there a neater way to implement client side prediction and similar networked physics using BEPU? It essentially requires movement code for players to be processed independently of the world space with custom time deltas, so that the server can update each player the same way the client would have done. I am currently doing this by freezing the world and performing multiple space updates per frame, but this may cause efficiency problems as the number of players scales.
Thanks,
Greg
So I am implementing a client server networked fps and my solution for client side prediction involves freezing all other players while processing the current input on the server. I have it working so that players will not move during an update if I take these steps:
1. make entity kinematic
2. set entity velocities to 0
3. space update
4. make entity dynamic (uses saved local inverse inertia)
5. set velocities back to pre-freeze
However, I now need to implement objects on the server which can move the players during updates when there is no input, so simply freezing the player to update the space will no longer work. Using an elevator as an example, when the elevator updates but the characters body is kinematic, it will not be pushed up by the elevator but will instead begin to fall through it.
I thought a solution that would be simple given my current implementation would be to eliminate the kinematic and dynamic part, so that elevators can still move the object but the controller input should not be applied until required. If I do this however, the entity still moves
1. set entity linear velocity, rotational velocity to 0
2. space update
3. set velocity back to pre-freeze velocity
As well as this, I check in my CharacterController's IBeforeSolverUpdateable.Update(float dt) method whether or not the character should be frozen and this method does not get updated when it shouldn't. So my question is what could be causing an entity with a character controller attached to be moving, when I set the velocity to 0? Are there other updateables in the character controller code which need to be disabled for these updates? When the character is on normal ground I would like the update to happen as if the character was kinematic, but it still needs to be pushed by certain dynamic objects such as elevators.
PS. Is there a neater way to implement client side prediction and similar networked physics using BEPU? It essentially requires movement code for players to be processed independently of the world space with custom time deltas, so that the server can update each player the same way the client would have done. I am currently doing this by freezing the world and performing multiple space updates per frame, but this may cause efficiency problems as the number of players scales.
Thanks,
Greg