2
\$\begingroup\$

I'm working on a 2D javascript/Three.js multiplayer game, using web sockets and an authoritative server currently written in Python.

The combat mechanic will be similar to Geometry Wars however i'm struggling to get my head around how to implement this in an efficient way.

There are several drawbacks/concerns I need to take into account:

  • Efficiency is key
  • Three.js particle systems aren't mutable, you cannot add or remove particles once the system has been created, only move them off screen
  • All calculations with respect to collision and damage must be done server side
  • My game currently implements entity interpolation with fixed time step updates from the server
  • Potentially several different weapons/projectile types

I can see several solutions:

Handle each 'bullet' particle individually

Pros

  • Most accurate way of doing thigs

Cons

  • Slow on server
  • Lots of bandwidth
  • Hard to batch draw objects, will have to draw each individually

Use ray casting on server and have some form of network synced particle emitter

Pros

  • Much easier on the server and network

Cons

  • Network synching issues
  • What happens when a bullet hits an object? Bullet will pass right through

Use ray casting on server for collision/damage and use raycasting on client for more accurate particles

Pros

  • Much easier on the server and network
  • Will look more accurate

Cons

  • May still have some synching issues
  • More work for the client

Obviously the amount of players currently connected will have an impact on the implementation, I would ideally like to allow hundreds of players to share a game world but there may only ever by 20 or so on screen at once.

The mutable particle system is an issue for all of these but I would still like to use it as it is more efficient that drawing each particle individually. In a test I could have over 10000 particles all moving and still get 60fps.

Any help or comments on my though process would be greatly appreciated. Is there another approach that would be better?

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Use particle systems only for cosmetic things, and handle physical stuff (like bullets) separately? \$\endgroup\$ Commented Dec 21, 2012 at 11:10

1 Answer 1

2
\$\begingroup\$

Your players may hack your game. Verifying things on the server is good to combat that but potentially bad for performance.

Collision detection can fail if not done carefully. Say the particle is moving quickly and you're only testing for intersection with an object. If the particle moves from one side of the object, through the object, and on to the far side within one simulation time step then you don't detect a valid hit.

You might look at how ogre3d does particles. It sounds very similar to what you're looking at.

\$\endgroup\$

You must log in to answer this question.

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