How should i handle collision detection?

Started by
0 comments, last by GeekSharp 19 years, 1 month ago
Hello, iv written a very simple network game that uses a protocol looking something like this: The server owns and updates all AI's, missiles, etc. Position updates are calculated by the server and sent to the clients. The client's own's their own actor's that they own, for instance, every player own's a ship. They send updates to the server, and the server send these updates to the other clients. The question i have is, should i do collision detection only on server, or on client also? The problem with doing it on both, is that it may be out of sync, and if the client is allowed to handle his own collision respones he could cheat. But if you only handle it on server, what do you do when two ships collide for instance? Do you just override what the player send's as input with a "bounce" or something away from the object you collided with? That will look jerky on the client sending the input i think.. Anyone have any toughts on this problem? Thanks in advance.
Shields up! Rrrrred alert!
Advertisement
Hello peter_b,

The ultimate way, yet not the most practical/best way as far as I'm concerned, is to do it on both. You're right they might get out of sync. Actually, they will. You'll have to send packets from the server to the client saying "make sure you're at this location now with these states" and the client can then update himself if it's not correct. The more frequently you do these synchronizations, the more smoothly things will run. If you played UO, you might remember the days when you could run for three screens, but then suddenly you'd bounce backwards because there was a lag spike and the server says "whoa you didn't move there yet!" Elastic lag is nasty stuff, worse than just the pausing lag as far as I'm concerned. So the more frequent, the better.

But as I said, it's not necessarily the best way. The fastest way would be to let the client do their own updating, but they will most likely cheat. The only other way is to let the server do all the calculations and send the updates back to the player. But then you'll have speed issues if it's a fast game, or there's a lot of data.

I think you wanted an answer and I just restated your question. You obviously don't want cheating so in your case I would probably do the updates on both and just make sure you keep tabs on synchronization. You might even want to move the missile updates to the client as well and do the same thing with those. However, if you don't experience latency speed problems with only using server updates, then go for that, it's simple. Only try to solve the problems which actually exist right?
---------------------------------------------------------------"The problem with computers is they do what you tell them.""Computer programmers know how to use their hardware."- Geek#

This topic is closed to new replies.

Advertisement