Saturday, June 16, 2018

c++ - Should collision detection be done server-side or cooperatively between client/server?


I am working on an online game that will have very heavy collision detection processing. Player models will collide with other players, mobs, structures, terrain, and solid objects that only exist server side (not stored in client data files).


For security purposes, should I do all collision detection server-side? Or should I have the client do the detection and have the server follow up on it somehow? I feel like it will be too much for the server to do by itself (I am designing the engine for hundreds of players on one server).


Does anyone know how mainstream MMOs do it? I know that almost all MMOs right now are susceptible to physics hacks and usually deal with them by detecting hacks and banning people. I would rather the hacks did not work at all, at least for the physics component.



Answer



It seems like the obvious answer is to do most of your detection client-side (for smoothness), and then you interpolate to what the server says if your client is too far off. The server will tick at a less frequent rate than the client (like, say, 10hz), and would probably need to have some basic "can this player have reached where he says he currently is from his last known location" code, which implies some kind of nav mesh-type solution and pathfinding.


That might be prohibitively slow depending on what your needs are. You might make a design decision, for example, to not care about player-player collision on the server. Most games, as far as I know, don't even care about that on the client. It really depends on what your needs are.


But the rule of thumb is that you should never trust the client. It if impacts gameplay, you have to at least verify it on the server.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...