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 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?

share|improve this question
4  
Use particle systems only for cosmetic things, and handle physical stuff (like bullets) separately? –  Jari Komppa Dec 21 '12 at 11:10
add comment

1 Answer 1

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.

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.