Collision over network

2329e35b4126024a8ff56b9e0cbf14bf
0
bejan0303 101 Sep 23, 2009 at 05:47

Hello all, I have plans to make a client/server “game”, that consists of several users logging on and just moving a character around in space, mostly just for fun. I am currently working on the server end of things and was looking to see how to handle the collision detection, i have read over and over that it should be on server side. So is it better to give each character there own thread for it? or is it all together? Im just not sure what would be most efficient. Also, I have been looking on forums and googling, so if Ive just missed it I apologize for wasting your time but appreciate a link. I dont think its relavent, but I am using c/c++. THANKS!

3 Replies

Please log in or register to post a reply.

5225bc0c3bf66f4c275c332de6388d1f
0
SyntaxError 101 Sep 23, 2009 at 15:22

By space I’m not sure if you mean floating around in vacuum or something else. In any case ….

A lot of games do collision detection (character to environment) on the client side. Collision detection can take a fair amount of CPU depending on a lot of factors. If you are trying to do it all on the server I think you will run into problems. More importantly there is the lag issue. A player has to be responsive on the client even if the server communication is not optimal. You really need to do some collision detection on the client or players will be running though walls and things. Player to player collision is a different story. First it takes less CPU for doing basic player to player collision and second the server holds the true location of a player. The down side is collisions can be somewhat off from what the player is experiencing. Note games like WoW do don’t even do player to player collision.

There are a few other factors to consider. Are you going to do prediction for other players’ position or are you just going to allow them to be slightly behind their actual position? In old EQ I believe they used prediction. On occasion a player would run off a cliff and then pop back to his real position. In WoW you never see this, however if you are running on two accounts with two characters you will notice a character is always slightly behind his true position. This means you can get away with just doing collision detection for a single character on each client and never have to worry about seeing players majorly off their course. Don’t quote me on any of this. This is just my guess from doing tests on these games.

You need to think about what’s acceptable to you and how you want the players to experience the world.

6837d514b487de395be51432d9cdd078
0
TheNut 179 Sep 24, 2009 at 02:36

As SyntaxError stated, it depends. If you want a high quality server with good anti-cheating mechanisms, you should validate player positions and prevent them from walking though walls or sending them data that is occluded from their vision. MMOs may take shortcuts because they are already cpu intensive and not many people will care, but games in the 32 player market should support validation.

5225bc0c3bf66f4c275c332de6388d1f
0
SyntaxError 101 Sep 24, 2009 at 03:19

@TheNut

As SyntaxError stated, it depends. If you want a high quality server with good anti-cheating mechanisms, you should validate player positions and prevent them from walking though walls or sending them data that is occluded from their vision. MMOs may take shortcuts because they are already cpu intensive and not many people will care, but games in the 32 player market should support validation.

I actually ignored validation in my last post. Of course some form of preferably low cost validation can also be applied on the server. My main point was that you typically still need client side collision detection at a minimum because otherwise there is nothing to stop a player from appearing to walk through a wall. In fact you will probably fall through the floor pretty readily. The client of course can fix this and put you back where you are supposed to be once it receives an update from the server. However that means you will appear to be bouncing around if you are running against a wall. Or worse you will be bouncing up and down on the ground.

I’m not sure any client/server games use pure server based collision detection. The lag would have to be pretty low and even then I would think the bouncing would be noticeable and very annoying. I was annoyed by a small jittering in corner situations caused by a bug in my CD code before I fixed it. Anything caused by server lag would probably make me want to punch my monitor.

Edit: Actually after reading the OP’s post again, I’m wondering if I misunderstood it. I read it to mean all collision detection should be done on the server as opposed to additional collision detection should be done on the server. If he meant the latter …. hopefully I still said something remotely intelligent :-P