Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can't rewind a ParticleSystem. Bug?

Discussion in 'Editor & General Support' started by gazialankus, Apr 23, 2012.

  1. gazialankus

    gazialankus

    Guest

    In my code I need to rewind a Shuriken ParticleSystem, just like I can rewind it in the Editor by dragging Playback Time.

    The script reference says this is possible by setting the time property, but it doesn't seem to work.

    There is more information and sample code on the question I submitted here: http://answers.unity3d.com/questions/243231/rewind-particle-system-shuriken.html

    Is this a bug? Did anyone ever set the time property and see it affect anything?
     
  2. WBDN

    WBDN

    Joined:
    Dec 23, 2011
    Posts:
    109
    Hi!

    The .time property only affects the emitter time. It does nothing to affect already existing particles. the way this can be used is if you have curves set up for start energy, start speed etc, then you can control the time of the emitter.

    If you want to affect already emitted particles you have to use Simulate(). Unfortunately there is a bug that makes this quite broken, but if you Stop(), Clear() and Simulate(time) on every update, you should get something. This is fixed and is to be released in a future version. Additionally, this operation will be much faster than it currently is in most cases.
     
  3. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    Was this ever fixed. I am trying to manually simulate the Shuriken softsnow particlesystem in the update loop using stop,clear and Simulate(t)
    where t counts slowly = .01, .02,.03...

    All I see is the snow jumping around randomly instead of falling slowly every frame.

    Is there a fix available?
     
  4. Gamgie

    Gamgie

    Joined:
    Jun 7, 2012
    Posts:
    7
    Hello !

    I have the same bug. It is said to be "This is fixed and is to be released in a future version".

    Is this still bugged or there is now another way to do it ?

    Thank you !
     
  5. Gamgie

    Gamgie

    Joined:
    Jun 7, 2012
    Posts:
    7
    I can actually go backward if you do something like this in the update loop (with a randomSeed fixed) :

    Code (CSharp):
    1. float playbackTime = particleSystem.time;
    2. particleSystem.Clear();
    3. particleSystem.Simulate(playbackTime - Time.deltaTime);
    4. particleSystem.Play();
    It works well. But it begins to fail reaching a mystery time (for me it is after ~4.7s). The Simulate function seems to go to the same result for every time after that limit.

    Is this a bug ? (or maybe I am doing something wrong).
     
    Hrusilov likes this.
  6. pet1100

    pet1100

    Joined:
    Mar 14, 2017
    Posts:
    1
    What gamgie said works perfectly. On a few extra condition.
    Simulation speed is set to 1. (It hasn't seemed to work with anything else, but there might be a fix I haven't found/seen)
    Particlesystem has to be stopped before setting a seed. (Always!)

    particleSystem.time only give the current time of how far it is in the loop.
    For a full rewind you need something to check how many cycles it have gone through.
    And then multiply that with particleSystem.duration.
     
  7. JDatUnity

    JDatUnity

    Joined:
    May 15, 2017
    Posts:
    7
    Could you perhaps elaborate? multiply what with what?