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.

Let's assume the following:

  • I have a server which stores the player's position (float x, float y, float z)
  • Client sends the server it's updated position ever 250ms or so.
  • Server has bounding boxes for all buildings & players ( Let's say each wall has it's own AABB or OBB)
  • For broad-phase collision detection, I use spatial hashing based on the bounding boxes.
  • Client does full-on triangle level collisions locally.

My question: - How can I quick calculate if a player has passed through a wall on the server only using AABBs or OBBs. Or, is there no way to do that without going to triangle-level collision detection. Maybe some other data structure? Any help would be appreciated.

share|improve this question
    
Forgive my possible misunderstanding as I am not familiar with MMO design, but if the client handles collision detection locally, why do you need to check it again on your server? If the player does the detection themselves and sends their location to the server, you should be able to assume that they have never passed through an object. I realize that players can cheat and send faulty vectors to the server, but that point a side I don't see why you need to know if they have passed through or entered a wall. –  Benjamin Danger Johnson Feb 5 '13 at 20:54
2  
Exactly the point of whether or not they cheat by sending false movement information. Let's say that you cannot get through the other side of the wall because of the some objective. Player's can bypass this by "going" through the wall client side. I need the server to be able to tell if they illegally went through a wall or not. –  user1432882 Feb 5 '13 at 21:18
    
What does AABB and OOB mean? –  user25712 Feb 5 '13 at 21:23
    
axis aligned bounding box & oriented bounding box (made a typo for last one) –  user1432882 Feb 5 '13 at 21:25
2  
@BenjaminDangerJohnson Players being able to cheat is not an issue you can just brush aside. A well-designed netcode is always better than tagging on an expensive, error-prone and hackable anti-cheat tool or hiring an army of game masters. Also, there are other situations where server-sided collision detection matters. Script triggers, for example. –  Philipp Feb 5 '13 at 21:26

2 Answers 2

As many other answers indicated, you really should not let the client handle crucial data such as collision detection or positioning. If you let the client determine where it is going and if it can go there, you are making your game an absolute sitting duck for ill-intentioned players and hackers.

I highly suggest you redesign your client-server relations so the client only sends input information and receives data about the world and other objects in it, leaving all the processing to the server.

To minimize the amount of data sent back and forth, the client should send only input messages such as "Player started/ended pressing W", "Player rotated the camera by X,Y,Z degrees" (the server needs to know this if moving the camera during movement will change locomotion's direction), etc. The server will then receive such data and process player's position and whatnot, accounting for collision and whatnot. If player is enabled to move (because there were no collisions with walls), both client and server will update the character's position within the world. If a collision comes to occur, the server will send a "HALT!" message and send the last valid position, and the client will pull the character back to such position. This saves the server from having to discretely send position data at given intervals.

Such method is, obviously, very costly serverside and is prone to position flickering clientside when the player is experiencing lag or high latency (which is not very bad on passive MMOs such as WoW, but it becomes a problem on very action-filled games such as Team Fortress 2, GunZ and Combat Arms). At least it will solve your presented problems and make the game a bit less hackable.

About your question per se: it depends on how the world is modelled. If the only non-passable geometry in the world is comprised of perfectly rectangular walls and nothing else, then you can get away with just OBB collision detections. However, if there are things such as mountains or round buildings, then you'll have to use per-triangle collisions and use some broadphase algorithm to only do such costly detections when absolutely necessary. A tip: you don't have to use the actual models for collision detection. You can make invisible meshes -with lower poly counts and simplified geomtery if compared to the actual models- to serve as bounding meshes and use their polygons on the per-triangle collisions.

share|improve this answer

Usually the situation is simply that if a player has cheated, you don't want them in the game. So in an MMO you can just disconnect them - no need for repositioning etc. Or if you're feeling generous you just send a message to put them at their previously legal position.

Beyond that, there's nothing specific to MMOs about how you do collision detection, and there are plenty of resources on how to do collision with bounding boxes.

If you're finding that you have obstacles so small that 2 positions sent from the player might make it seem like they passed through the obstacle, then you need to increase the position sending rate. No amount of calculation based on individual triangles can overcoming the fundamental problem of not having enough data about the trajectory. Just send more updates.

(PS. It's usually unwise to implement collisions between players and other players because many will use this to cause trouble by blocking players from their intended destination and perhaps denying them the ability to move entirely. So be careful what you do there.)

share|improve this answer
    
I think he's more or less interested in how to reduce the load of the computations in a server-based environment? I guess the trick is to just check for possible intersections and narrow it down. –  Vaughan Hilts Feb 6 '13 at 21:42
    
If he's only moving a player character 4 times a second then I doubt performance will ever be a problem. –  Kylotan Feb 6 '13 at 21:57

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.