Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am building a MMO game server for a 2D game and am currently implementing the collision detection, and I am would like to know what I should do.

Lets say I have 1000 players playing and 10,000 objects, should I just iterate over them all to determine if colliding? This seems a bit pricey.

I could separating the world into chunks and iterating every object for each player in it's chunk.

I would like to know some other ideas or what is standard. What's the best way for a MMO server to handle collision detection with static objects?

share|improve this question
    
I just found this, it adds to David's answer: gamedev.stackexchange.com/questions/3884/… –  Patrick Lorio Jan 5 '12 at 21:06
add comment

1 Answer 1

up vote 14 down vote accepted
  1. The world being separated into chunks is indeed the first step you should take, with each chunk being handled separatedly.

  2. Static objects? Purely static in the sense that they never move, and never disappear? Then you could simply incorporate these objects into whatever data structure you're using for player navigation in the world (such as a grid, navigation mesh or visibility graph). No need for doing any individual collision detection. This could be done manually by the designers, or automatically by the engine as a preprocessing step of the content pipeline.

  3. If on the other hand you'd like to actually perform collision detection between dynamic entities inside each chunk, depending on the expected amount of simultanous entities you might benefit from using a spatial partitioning data structure (such as a quadtree or a grid) to reduce the amount of entities that need to be iterated. In general, research the broader topic of broad-phase collision detection (no pun intended) which includes the aforementioned spatial division techniques as well as other approaches such as sweep and prune.

share|improve this answer
2  
Side note: a subset of all physics engines is utility for detecting collision, even if you don't use physics to move you can still use the collision detection if you don't want to write your own. –  Patrick Hughes Jan 3 '12 at 3:02
    
@PatrickHughes True. A couple years ago I spent hours trying to get OBB-OBB intersections working correctly using the separating axis theorem. Then in 5 minutes I dropped Box2D in and solved the problem. –  David Gouveia Jan 3 '12 at 3:06
    
Not to mention they already implement broadphase for you. –  David Gouveia Jan 3 '12 at 3:43
1  
Is it practical to 'turn off' all the other calculations in a physics engine to facilitate this? Often you don't want to try and perform proper physics on an MMO server because objects regularly move in a discontinuous manner. –  Kylotan Jan 3 '12 at 14:30
    
@Kylotan If you mean practical as in how easy it is to apply, in Box2D for instance it's just a matter of flagging your bodies as sensors and moving them directly. But I'm not really sure if there would be some hidden implications. I've never really tried this approach. –  David Gouveia Jan 3 '12 at 14:36
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.