Interesting ideas!
I’m not sure how this has turned out for you but I thought I’d jump on trying to give some input from my development perspective of Particle Playground.
Particle Playground can do what you’re asking and to run this into a networked solution I would recommend to run the entire particle simulation server side - if every particle need to appear exactly the same. What you probably would want in that case is to have one PlaygroundParticles object server side which calculates all particle positions - then each client side you have a “zombie” or, a little more advanced a lightweight prediction model, which inherits all/or parts of the particle data from the server. The most efficient way of doing it is though to let each client interpret its own particle system - which doesn’t require the server to send data into the PlaygroundParticles objects.
Anyhow! Sending data:
The essential data to transfer lives in the PlaygroundCache which you can access in every PlaygroundParticles object:
particles.playgroundCache // The cache is of type PlaygroundCache
There is a deep copy method available if needed:
var particleData : PlaygroundCache = particles.playgroundCache.Clone() // Copy all data
However it would be a waste of bandwidth sending that whole chunk of particle data. I believe what kind of data that has to be sent is a little bit different depending on how often you send it and what your particle system looks like. I’ll try to elaborate,
Zombie client
The server runs all particles each frame and just tell each client where every particle is. This method would mean it’s highly depending on server-client connection and speed - a lot of bandwidth will be needed throughout the simulation. You would essentially overwrite the entire PlaygroundCache for each client every time it receives an update from the server.
Prediction client
All clients get the entire PlaygroundCache data from the server at the beginning of simulation. However, each client run their own simulation of the particles and gets updated asynchronous from the server. Here the most essential data would be to send (depending on what settings you have on the Particle Playground System):
- Size - Particle size (if you resize them during their lifetime)
- Life - Lifetime of each particle
- Birth - The time of birth
- Death - The time of death
- Velocity - The speed and direction of each particle
You would add a layer in between the server and client particle data, where the client will compensate towards the server’s velocities, each birth/death and size (if applicable). This could be as simple as a for-loop on the client side iterating through the received data from the server merging the numbers and finding the median value.
When the source moves (if applicable) on the server side, let it broadcast the data for:
- targetPosition
- previousTargetPosition
No data:
No server simulation
A third solution, which would be the quickest way to success is to let all clients run their own interpretation of the particle systems. Now, these can appear a bit different depending on your settings, but it’s quite easy to get similar results on all machines. They would differ as much as a Preset differs each time you instantiate it.
The server would only take care of all connected transforms to the particle systems, Particle Playground on each client will do the rest of calculations.
What’s interesting is that you could attach manipulators to each player (AI, objects etc.) and let them interact with the particles with a low cost on performance. Based on the essentials from the network methods mentioned all players would see the interaction which would appear to happen in realtime on all machines.
You mentioned collisions, these are currently highly depending on available frames as there are no logic that will check for “passed” colliders. Collision detection will have to run always on clients (and server if you send data). I’m hoping to update this in the future which will improve the collision appearance a bit. What’s positive is that you can manipulate the particles and still maintain collision detection (as long as they’re moving). Remember that it’s quite a heavy operation for thousands of particles, but should still be fine for around 3-4k particles each frame.
I hope it helps, otherwise ask and I’ll try chip in again!