Advertisement

Collision Detection Algorithm For Network Game

Started by October 12, 2002 05:00 PM
2 comments, last by toroso 22 years, 4 months ago
Hi All, I''m working on a network game and it''s time to solve the collision detection. I have found a few algorithms that all presume that the objects don''t move much between frames. However, now that I''m working on a network game, the position information that comes from the other computers will be as old as half the ping times (maybe up to a few tenths of a second) and therefore I can''t assume that the objects don''t move much. Can anyone direct me to an algorithm that handles this?
you handle the information differently. the server runs the "true" version of the game, i.e. anything that happens on the server is final. the clients just send their input to the server (say "move forward") and the server will update their position and perform all nessisary collision detection. the server then sends out the player''s new position.

dont ever rely on the client for positional information, only input, otherwise they could cheat very easily. ask in the network and multiplayer forum for more details.
Advertisement
What MENTAL said is true, however you don't want to wait for the server with everything . What I am alluding to is called clientside prediction. Basically, between server updates, the client updates game information based on the previous update, thereby "predicting" what the true data really is on the server. When the server sends the update, it overrides predicted client data. It keeps the game running smoothly for people with higher latency.

[edited by - Zipster on October 13, 2002 1:26:50 AM]
Thanks for the replies, although it does not really give me the answer.

Say that I do what you say, let the server have the "true" game. A client sends its object position to the server. When the server gets the position, it is, say 100 ms old according to the game timer. In that time the object will have moved, say, 100 pixels (it''s a 2D game). If the size of objects is 50 pixels, this means that the client object might have collided with another object without the collision detection noticing it -- UNLESS I use an algoritm that does not only look at final positions, but also the movement there. Algorithms that I have found only look at the final position.

t = 0 ms
|---|       |---|| 1 | -> <- | 2 ||---|       |---|

t = 100 ms
   |---| |---|<- | 2 | | 1 | ->   |---| |---|

It''s not that difficult to come up with something that handles this. However I am sure that someone more clever than me has already spent a respectable amount of hours coming up with an excelent solution.

To respond to your answers though I can tell you that I am thinking of using a peer-to-peer connection. The reason is that my game will be very sensitive to network latency, and communicating through a server would double the time it takes for object positions to get transferred between clients. The problem with cheating I will have to address in some way, but I think that having a game server will not be my solution.

I will also have to use client prediction for minimizing the latency sensitivity.

I hope I am in the right forum. What I am looking for is an algorithm, not common practise for network or multiplayer games.

This topic is closed to new replies.

Advertisement