- Home /
How to script Shuriken ParticleSystem.Simulate() to emulate editor behaviour
I'm making a "time vortex"/hyperspace/trippy particle tunnel sort of effect, and while playing with the particle system settings in the editor I've found an effect I quite like. Now, I'm trying to replicate the visual effect at runtime.
What I did: I've set up a Shuriken particle system, emitting from the base of a cone, with a forward acting force-over-lifetime, so the particles form a tunnel of sorts. I got the effect I liked by decreasing, in the editor, the start speed variable. This "squeezes" the tunnel and gives it a focal point once the particles intersect. Further decreasing the speed (into the negatives) gives a nice "passing through the particle cloud, breaking through to the other side" effect.
Now, this works because changing the speed in the editor "backdates" and updates all particles, putting them at the location they would have had, if they had been emitted with those values.
I can easily script or animate the decreasing start speed, but of course at run time, this only affects new particles, emitted after the change. So, now I'm trying to use ParticleSystem.Simulate(Time.time, true, true) to re-simulate the particle system, using the changed speed. It kinda works - but it breaks after Time.time becomes greater than the particle's life time. Then, the particles freeze in place and kind of stutter back and forth a bit. I've added system.Stop() and system.Clear() but this doesn't seem to have any effect. The documentation on these function is extremely sparse, so I was hoping someone can tell me either how to achieve what I'm trying to do, or confirm that it's not possible (for example, because Simulate() just won't work for durations longer than a particle's lifetime).
I've added some screenshots, but it's hard to get the effect across as static images. Still, maybe they'll give you a clue!