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'm developing an MMORPG, using Unity for the client and "standard" C# 4.0 for the authoritative server. The server should check each player's movement and ensure that it does not collide with props or walk through unpassable terrain (like a cliff). Collisions with other players and such are not checked. In addition, the server must be able to retrieve/calculate the position of a player at any time so it can be sent to other players (who just walked into range, for example).

To make this all a little more complex, the game is a 3D space, meaning you can have things such as a spiral staircase and flight, and it has multiple maps.

I've run into a problem, though. I'm not quite sure how to actually implement all this.

I've come up with two ideas:

  • Make the server interop with a Unity client tasked solely with tracking player positions and validating movement
  • Get the props and terrain onto the server and use math to define the character's movement and check for collisions.

The first one seems ugly to me, and I don't even know if Unity will allow me to load multiple maps onto the same client. I've made some progress on the second one: I managed to export props as OBJ files and read them on the server. But from there, I'm kinda lost.

My question is two parts: Is there a better way to achieve what I want? And if not, how should I proceed with my current plan?

share|improve this question
    
You could make a nav mesh per area that represents the traversable area and use that data on the client and server for collision and pathing. –  Tetrad Jul 22 '13 at 20:49
    
@Tetrad that wouldn't let me determine the position of a moving player at an arbitrary point in time, would it? –  Xcelled194 Jul 22 '13 at 22:35
add comment

1 Answer

You seem to allow in your game to flight, so traversable area is not a good solution.

If Unity has a library or somthing like that you may embed into your server and it run fast enough to work with lot of client, I think you should use it, because implementing a collision engine is a huge job. You may always prepare your code to allow a further transition to your own collision engine.

Accuracy for a simple collision engine:

  • It is important your server colision engine be less strict that your Unity client colision engine: if not, the server will be every time fixing players movement, and with the network lag, that is very painful for players.
  • The server should test colision using the (near) full player trajectory, not only the start-end position.
  • If the server is much less strict than your client, you allow cheaters to use this margin to get advantages.

Considerations for a simple collision engine:

  • You should use a simplification of the entire world, which exclude small objects and simplify geometries.
  • There is lot of libraries that you may use to avoid the bigger part of this task: collision and physic, some of them use GPU hardware acceleration (like phyx)

Finally: take your time to evaluate all options, because this decision has big impact on the result quality and implementation time.

share|improve this answer
add comment

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.