Hi I am new here, I started a little game project. I have still created a Server and a client which can successfully exchange messages. Currently the basic game-logic is still in the client. Now I am starting to move all the game-logic to the server and the client should only render the output, provide the movement input to the server and should also compensate the jitter / lag from client to server or the opposite direction.
- My first problem / thought is about the collision detection which is if I do it on the client side (like I do it now) no problem. If I move the collision detection to the server I not really sure how to do it. I load my terrain out of an high-map. So should I load the terrain out of the high map like before and generate the CollisionShape + RigidBodyControl and for the player the CapsuleCollisionShape + CharacterControl and add the player and terrain to the physic-space of the bulletAppState (and don’t add the things to the root node)? If I do it like this way, would I be able to detect collisions without graphical output on the server side? How should I do this?
- My second problem / thought is about the movement of objects and the player its self. I read the following articles:
Source Multiplayer Networking - Valve Developer Community
Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization - Valve Developer Community
So the server does all the simulation work. The Server has the “game time” which is send to each client. each client corrects this time by the delay of his connection to the server. So the time is nearly synced (nearly because you wouldn’t be able to sync the time by 100%).
With this game time you can handle actions in the past. The time is added by any updates of the server or by any command of the client. The client has to check if the time is still in sync after each update the server sends, if not the client has to correct it to become back in sync.
The Server stores all the positions of a moving objects for some time (lets say 1sec). Now the server is able to add movement-commands or run hit-detection for shooting-actions for the correct time, because of the network-delay client commands will arrive delayed while the game simulation is still going on.
So for this behaviour I have to store a array of positions for each of my moveable objects?
The client it self couldn’t wait for the response of the server after each movement command, the game would look laggy. So the client dose a movement prediction. The client stores ale the commands in a list which have been sent to the server. The Client adds the command to the last position which is received by the server and this is the predicted new position. this position is used for the next rendering run and also saved in a list with the time stamp when the movement command was send. So after the next update of the server the client has to check the received movement positions of the server against the positions the predicted positions of the client at the specific time. If the predicted position + a little difference doesn’t match the client has to re calculate all the commands starting at the time where the miss-match was found.
Have I understood it right? So The movement-command of the client would be an vector-direction and speed information? When the player stops moving the client sends a a direction for the view direction and 0 for the speed?
Or how do you solve the movement problem in your games? Can you please explain it to me, the thinking about it drives me crazy