12
\$\begingroup\$

In an MMORPG:

Is it typical or feasible to store the coordinates of every tree, bush rock.. etc in the server side for collision detection?

If so, what would be a feasible way to store such a huge number of coordinates (data structures and such, performance issues handling)?

If not, is this type of collision detection done entirely in the client side, with the server not checking at all?

Or is there a middle ground, with the client checking collision and server verifying? If so, how would the server verify the same without keeping the coordinates in the server as well?

\$\endgroup\$
4
  • 2
    \$\begingroup\$ I don't know enough about this to give a good answer, but if you do collision detection only on the client side, cheaters will find a way to clip through everything, or pick up powerups that are miles away from them. \$\endgroup\$
    – Peethor
    Mar 29, 2016 at 5:09
  • 2
    \$\begingroup\$ -1 "Question does not show any research effort". \$\endgroup\$
    – Vaillancourt
    Mar 29, 2016 at 13:57
  • 1
    \$\begingroup\$ Possible duplicate of Should collision detection be done server-side or cooperatively between client/server? \$\endgroup\$
    – Vaillancourt
    Mar 29, 2016 at 14:01
  • \$\begingroup\$ actually, probably not a duplicate, I learned about spacial partition schemes and spacial data structures that the other question didn't have \$\endgroup\$ Mar 30, 2016 at 5:18

2 Answers 2

15
\$\begingroup\$

Independent of feasibility (yes, depending on scale) there are often better or easier ways.

For instance, in your typical MMO, the server really only needs to know about the coarse navigation map used by AI and player pathfinding. Instead of storing the location of a tree, you can instead just cut a hole into the navmap at the location of the tree. Likewise for any other big obstacles.

Even games that need more in-depth collision detection, you can often break this into server- and client-side detection. The server can just concern itself with coarse pathing while the client handles more animation-sensitive collision detection. For instance, a wounded player tries to crawl along a big rock to find a hiding place from enemies. The server determines that a player could move along the edge of the rock (the server has no idea that there is a rock, just that there's a path the player can take next to an unpathable area) while the client knows that the rock is present and plays an animation of the character propping itself against the rock as it walks. Note that the client isn't moving the character or impacting gameplay in any way in this case; it's just reacting to the nearby objects with an animation.

You certainly can store large numbers of objects on the server. It's no different than any open-world game. Use a good spatial partitioning scheme and keep the memory footprint of your objects as light as you can. Note that we may have different versions of "large numbers" in our heads here: if you meant that you wanted to store every little pebble or rocky bump in the game as a separate object then that's just silly, even for a single-player game. :)

\$\endgroup\$
7
\$\begingroup\$

Yes - it is feasible. MMOs often split the game world into multiple areas, as this makes the job easier, but you can still do it with 1 massive area - you just need to use a good spatial partitioning scheme.

Because most objects in MMOs don't move, you can also perform a preprocessing pass where objects are used to create collision checking trees.

Memory footprint isn't a huge issue here as long as you use instancing. Storing a couple floats per object is nothing in the grand scheme of things. A modest PC nowadays will have 4 gigabytes, while storing a position is just 3 floats (or 3 doubles) - which would easily allow several million stored objects in-game.

Storing things like inventories for each player would undoubtedly take up more data - although that can easily be cached to disk and only loaded when a player logs in.

You'll want to redundantly do the collision checking on the client as well as the server, as this'll allow the client to more responsively react to the environment. If a player walks into a wall, you want them to stop moving immediately - not after half a second when the server responds.

You only want to use the server for authoritative things, too. For example, you would perform pathfinding only on the client, as you can't cheat by taking a less efficient path!

\$\endgroup\$
1
  • \$\begingroup\$ thanks for the tip about spacial partioning schemes, I learnt something new \$\endgroup\$ Mar 30, 2016 at 5:18

You must log in to answer this question.

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