   Theoretical question - maps, collision & npcs
  Hey, we're currently developing a multiplayer game and we're at the part where the levels and characters are designed.And now we're wondering what to do with, we have the following issue:Q: Where should we place the the collision detection?Scenario 1:- We currently calculate the players position on the server. But currently the character can walk through meshes like trees and rocks and that sort of stuff.The engine that we use provided a function OurMesh.AdvancedCollision() to detect where a collision has taken place. But this is done on the client.Then we can tell the server that a collision occured and the client also tells the server to reset the characters position to just before the collision occured.So it won't be placed inside a mesh, but just infront of it.Scenario 2:- The other choice would be to do the collision detection on the server.Imagine a map/world with a few sepperate loaded meshes on it, like trees and rocks (just like in scenario 1).The client isn't the only one who loads the map, but also the server loads the map (in someway...) So the server knows on what location the trees are placed, and the rocks are placed.THen when a client moves, the server checks first if that new position is somewhere in one of those locations where a mesh is placed, and if so, then don't move the player forward.Scenario 3:Move the playermovent back to the client instead of the server, so the collision detection can be done on the client as well.This scenario seems to be prone to alot of stuff, like exploiting... And what happends when you have lag, and the movement is calculated on the client.. Teleporting (hax)?But i would really like to hear your opinion about this matter. What do you think what's best?   
  I don't know much about net coding but I think the first scenario is the most common solution for games which deal with a lot of players. If your server doesn't have to handle a massive number of players, I'd go with scenario 2.   ;  The first solution would enable a client to ignore collisions, thereby walking through walls and enemies and whatnot (just patch it to prevent it from sending collisions to the server). I would do collision detection on the server. Maybe you can also do it on the client for prediction, but the server should be authoritative.   ;Quote:Original post by lightbringerThe first solution would enable a client to ignore collisions, thereby walking through walls and enemies and whatnot (just patch it to prevent it from sending collisions to the server). I would do collision detection on the server. Maybe you can also do it on the client for prediction, but the server should be authoritative.Yeah that's true. I think doing it on the server would be the best option to prevent alot of problems later on.   ;  Both, but the server is authorative.So, both your client AND server run the movement but the client is only a 'local simulation' which allows for instance responses to the players input. At some point the server will send data saying 'you are really here' at which point the client will make any adjustments.The client never tells the server where it is, instead commands are passed down to make the server do the updates + validation.That way, even if someone DOES patch their client so they can walk through walls and ignore enemies the server itself, and all the other clients, won't get effected by this as the server will be validating input and the player's location. So, locally the player might think they are half way into a mountain, but in the game world as far as everything else is concerned they are walking dumbly into a wall and haven't noticed the dragon coming up behind them to eat their head [grin]   ;  Scenario 2 is obviously the correct choice.Now, if you're having speed issues, simply change your movement speed and latency on the server, and interpolate things somehow.Say you want to allow your character to move every 1/60th of a second on the client. The server possibly cannot handle that due to network latency, so you may choose to allow your character to move only every 1/10th of a second there, but to cover 6 times more distance.The trick is thus to run the client simulation at 60 FPS, but the server one at 10 FPS.Quote:The client isn't the only one who loads the map, but also the server loads the map (in someway...)Yes, but the server only needs a simplified map.   ;  Ok thanks, we are now confident enough to adjust the server and make it load (not render) the map too. After all this indeed seems to be the best solution.   