Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Shuriken ParticleSystem issues with particles being cleared

Discussion in 'Scripting' started by VesuvianPrime, Apr 3, 2014.

  1. VesuvianPrime

    VesuvianPrime

    Joined:
    Feb 26, 2013
    Posts:
    135
    Hey guys

    I'm trying to write a PointCloud component. The idea is to feed an array of particles into a ParticleSystem and have them stay exactly in that state until the next time I set the particles.

    I have this working to some extent. I've been able to work around the poor API and lack of Particle serialization, but I still have some situations where the Particles are cleared when I don't want them to be.

    [HR][/HR]

    Firstly, a quick overview of how my PointCloud works:

    $0df1aa4d9fdfd99472b6df1d628f4979.png

    Since the ParticleSystem API is so limited (read: pathetic) I have designed the PointCloud to take an artist's ParticleSystem prefab as a property. When the prefab is assigned it is instantiated and all calls to gameObject.particleSystem are routed to the instance.

    $51db5e343bb70e16ffe19f16700fc82e.png

    The DefaultPointCloud I am using for testing is an extremely lightweight GameObject with a single ParticleSystem attached. The ParticleSystem is only setup with a renderer:

    $b963045b4f73734dfd70968c358b3023.png

    I'm able to do a tiny bit of configuration in code when the ParticleSystem is instantiated:

    Code (csharp):
    1.         /// <summary>
    2.         /// We do some setup to make sure the particle system plays nice
    3.         /// </summary>
    4.         private void _SetupParticleSystem()
    5.         {
    6.             if (this.particleSystem == null)
    7.                 return;
    8.  
    9.             this.particleSystem.loop = false;
    10.             this.particleSystem.playOnAwake = false;
    11.         }
    This approach is giving me some pretty nice results. Specifically right now I'm just making loops of particles, but eventually I'm going to be creating all kinds of geometric shapes:

    $dfd7d2f3648aa9519aceb35d424764bc.gif

    So you can see I've got the basics down, however I have some edge cases that I am having a lot of difficulty figuring out. The absense of good technical documentation is not helping. Did I mention the API sucks?

    [HR][/HR]

    1) Particles are cleared in editor when the hierarchy ParticleSystem is selected

    When the ParticleSystem is selected the "simulation" begins playing, clearing all of the PointCloud particles. This is a huge pain if the artist wants to tweak some settings on the ParticleSystem to see how it looks.

    I need a way to disable this automatic playback. Calling Stop() on instantiation via code does not help. Disabling playOnAwake does not help either.

    Does anyone know how I can do this?

    http://answers.unity3d.com/questions/679511/how-can-i-prevent-particlesystem-from-playing-when.html

    [HR][/HR]

    2) Particles are cleared on play

    Imagine an artist is working on a component called RingPointCloud. The configure all the inspector fields to get everything looking nice, but when they hit play everything is cleared.

    Perhaps this stems from point 1, however in Awake I reapply my cached particles. This means that in one moment the ParticleSystem has all of my particles set and then (probably when the frame is drawn?) the particles are cleared.

    Why would Shuriken behave in this way?

    This isn't an Update issue, because I can then modify RingPointCloud while the application is running and see my particles.

    [HR][/HR]

    3) Calling GetParticles after SetParticles is unreliable

    Calling GetParticles after SetParticles in the same frame will return a count of 0 and fill the provided Particle array with nothing. I suspect this is because the particles are not built until it's time to draw them, however I would still expect the internal cache of particles to be returned.

    http://answers.unity3d.com/questions/678758/particlesystem-getparticles-returns-0.html

    [HR][/HR]

    I feel like the more I try to use ParticleSystem the more I find it to be too fragile. Like many other developers I chose to use Shuriken because the documentation says it's the latest thing, but perhaps I should use Unity's older particles instead?

    Maybe I'm just using ParticleSystem wrong, but I really feel like someone at Unity has dropped the ball here. ParticleSystem clearly has a lot of potential to make some stunning effects that run efficiently, but the support for additional development is completely inadequate.

    Is anyone else doing any serious development with ParticleSystem? Can anyone offer any advice?

    Thanks,
    Ves
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  3. VesuvianPrime

    VesuvianPrime

    Joined:
    Feb 26, 2013
    Posts:
    135
    Given the issue has been going since 2012 I'm guessing I can't expect a fix anytime soon.

    Am I going to have better luck with Unity's original particle system?
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Yes, with the exception that batching doesn't work.
     
  5. VesuvianPrime

    VesuvianPrime

    Joined:
    Feb 26, 2013
    Posts:
    135
    Well, it was very easy for me to convert everything to use ParticleEmitter instead of ParticleSystem. This has also resolved all of the issues I listed in this thread.

    Thanks so much for the advice, Dantus! Very painless!