Saving/Restoring particle system state

Hi,
I’m trying to save the particle system state and then later to restore it to enable “replay” of it. As of now I’m storing all the particle data (ParticleSystem.Particle), seed and emitter velocity in the key frames. In other frames I just store the time delta. But the replay isn’t 100% same as the original (I’m replaying using Simulate() method). So obviously I’m no storing enough data. But because particle system (and it’s subsystems) contains a lot of data I don’t know which of them are necessary and which of them are computed only, because storing all of them would increase memory usage a lot.

There are GetPlaybackState()/SetPlaybackState methods which do what I want, but the returned struct is an opaque one and cannot be serialized (edit: It could be serialized to bytes, of course but it’s “black box”).

So my question is if someone knew which mandatory data are needed for particle system to save it state so it could be replayed later? Or if someone knew which data are stored when calling GetPlaybackState()?

Thank You

GetPlaybackState()/SetPlaybackState were added for this exact use case. is there a problem with serializing it as bytes?

there is data that you have no access to from the public API, if you try and do it yourself.
you also need GetTrailData()/SetTrailData if you use the trails module.

Thank you for the reply.

I’m serializing it as a bytes right now, but because it’s a bit heavy (around 350 bytes IIRC?) I was hoping to trim it down. But after analyzing the data, they could be possibly compressed so it’s not as big problem as I tought.

Ok cool. It’s the minimal set of data to record the entire particle system state.
I’d imagine 350 bytes is insignificant next to the Get/SetParticles() data. (you also need that)

1 Like