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?