2
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$
    – Tetrad
    Jul 22, 2013 at 20:49
  • \$\begingroup\$ @Tetrad that wouldn't let me determine the position of a moving player at an arbitrary point in time, would it? \$\endgroup\$
    – Xcelled
    Jul 22, 2013 at 22:35

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .