Rewind particle system (shuriken)

I would like to rewind a particle system. I believe I should be able to do it by setting the time property, as the scripting reference made me believe:


Use this to read current playback time or to seek to a new playback time.

I see that we can rewind particle systems in the editor by scrubbing time. However I’m not having any luck with rewinding a particle system in code. Here’s what I’ve been trying it with:

    public class RewindParticle : MonoBehaviour {

	public float AfterSeconds = 2.0f;
	public bool rewinded;

	private float rewindStartParticleTime;
	private float rewindStartTime;

	void Update () {
		if (rewinded) {
			float rewindToParticleTime = rewindStartParticleTime - (Time.time - rewindStartTime);
			if (rewindToParticleTime > 0.0f) {
				Debug.Log("rewinding to time " + rewindToParticleTime);
				particleSystem.time = rewindToParticleTime;
				Debug.Log(particleSystem.time); //this corrently prints what rewindToParticleTime has

		if (particleSystem.time > AfterSeconds) {
			if (!rewinded) {
				rewinded = true;
				rewindStartTime = Time.time;
				rewindStartParticleTime = particleSystem.time;
				//these didn't help either
				//particleSystem.Stop(); //this stops it for good
				//particleSystem.Pause(); //this just pauses it

Here’s what the output looks like. This starts after 2 seconds. I believe my code is correct:


rewinding to time 1.997295


rewinding to time 1.980445


This goes on until it reaches close to zero. However, the particle system that I’m looking at doesn’t care, it just plays as if I’m not setting the time property at all.

The conclusion that I reached so far is that this is a bug and Unity simply ignores setting the time property of ParticleSystem instances. Am I missing something or is this really a bug?

Thank you.

You need to set the random seed, to make sure you have a deterministic simulation and call ParticleSystem.Simulate (). For example:

using UnityEngine;

public class Rewind : MonoBehaviour {
    float time;
    public ParticleSystem particleSystem;
    void Start (){
        particleSystem.randomSeed = 1;
    void OnGUI (){
        time = GUI.HorizontalSlider (new Rect(5,5, 200, 20), time, 0, 10);
        time = (int)time; // to animate the simulation in steps
        if (GUI.changed)
            particleSystem.Simulate (time, true, true)

This is being answered in the forums:

Little Late but I needed the particle system to restart too, sadly this is how I had to go about it.


particleSystem.Clear();  // if you do not clear, it will keep old particles when you turn the object back on. 


This is how I use it.

//Particle system is turn to play on awake. 

private bool particlesShouldBeOn = false; // this is the bool that controls the particles
void Start(){

IEnumerator FlipParticlesOnAndOff ()
				while (true) {
						myParticles.Stop (); //Stop the particle system 
						while (particlesShouldBeOn == false)
								yield return null; //wait till bool flips
						myParticles.Clear (); // clear any particles that remain.
						myParticles.randomSeed = 0; // randomizing seed
						halo.SetActive(false); // <--- work around as Stop() does 
                                                //not rewind but Awake does....
						halo.SetActive(true); // < -- start back up. 
						while (isCharged)
								yield return null; // Wait till we flip the bool off