Search Unity

Animate particlesystem for seamless looping

Discussion in 'General Graphics' started by Sandler, Jan 11, 2016.

  1. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    Hi guys,
    i was wondering if there is a way to create a seamless particle animation, which can be played in a loop.
    Need this for animating smog on mobile, by creating a texture animation.

    If unity does not support this, are there any programms / librarys where you can create such seamless animations?

    Thanks!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Yes it should be possible. Use a looping particle system and make sure you set the system's random seed to a non zero value using a script.
     
    theANMATOR2b likes this.
  3. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    Thanks for your replay, i already tried that, setting the random seed property to 1.

    void Awake(){
    particles.randomSeed = 1;
    particles.GetComponent<ParticleSystem>().Play();
    }

    But this has no effect. The animation is still complete random (tested with loop, without loop, prewarm, etc). Its like the seed value gets ignored completely, using 5.3.0f4.
    And even if the seed would be used, since its a endless range, this wouldn´t mean that it repeats seamlessley, or did this work in older versions?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [ExecuteInEditMode]
    5. [RequireComponent(typeof(ParticleSystem))]
    6. public class ParticleSeamlessLoopScript : MonoBehaviour {
    7.  
    8.     public ParticleSystem ps;
    9.  
    10.     void LateUpdate () {
    11.         ps = GetComponent<ParticleSystem>();
    12.         ps.randomSeed = 1;
    13.         if (ps.time >= ps.duration)
    14.         {
    15.             ps.Stop();
    16.             ps.Play();
    17.         }
    18.     }
    19. }
    20.  
    Works in the editor, but only when not in play mode! The seed is still somewhat respected in play mode, but you need to spawn a new particle system each "loop".
     
  5. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Hi @karl_jones , could you confirm this is working / not working in the latest U revisions? I've tried (to no avail):

    - turning off auto random seed
    - resimulating/clearin/stoping&playing when simulation time reaches its end.

    Tested on using U 5.4.3.
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Do you have an example project?
     
  7. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Hi Karl,
    my project is too big, will make an extract, meanwhile will check on the latest version. The effect I am aiming at is ground particle fog that just stays there.
    Thank you!
    Best
     
  8. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240