Sign in to follow this  
dongzhe

who should handle the collision, client or server?

Recommended Posts

dongzhe    114
should client handle the collision, or server? or may be both? as far as i know the logic for collision should be in server- side, but there are some thing that i don't understand. let's say I drive the tank on the map that contains river which tank can't come over. if in client side there is no collision logic, when I press the go forward key and this package has been send to server, then the network got the lagging for few second. imagine if the tank is very close to the river, as result of prediction and no collision detection in client, the tank will go into the river, right? can any one explain how it works? so confuse me now..

Share this post


Link to post
Share on other sites
Hodgman    51237
If the client lags out (with not collision check on client, but some movement prediction), then the tank will go into the river -- but, then when packets are received from the server, the tank will appear back in the correct position (next to the river).

To fix this problem, add the collision checks to the client's prediction code as well.
If you design your code right, then the same code can be run on both the client and the server (except the client's state can be overridden by server updates).

Share this post


Link to post
Share on other sites
TheTroll    883
Collisions should be done both on the server and the client, but the purposes for those checks are different.

On the client it is to give the realistic game play of your world. On the server it is to keep people from cheating.

There server wants to make sure that people are not walking through walls and things like that. So your collision detection can be fairly general and have much less granularity then the client.

theTroll

Share this post


Link to post
Share on other sites
EJH    315
AFAIK, most games do both.

Collision of players with terrain and other players: usually done client side with server side sanity checks.

Collision of projectiles: can be simulated client side, but must be resolved on the server to prevent cheating.

Share this post


Link to post
Share on other sites
hplus0603    11348
Typically, you will draw the collisions/smoke/blood spurts/whatever when the client detects the collision, but you will actually remove hitpoints from the target when the server detects the collision. If it's likely that there will be lots of discrepancy between client and server decisions, such that the client will often be wrong, though, you may wish to delay drawing the hit effects until the server tells you you actually hit.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this