Search Unity

ParticleSystem doesn't play

Discussion in 'Scripting' started by litebox, Dec 26, 2015.

  1. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    Hi,
    After I update to Unity 5.3.1f1 from 5.2.3f1 my particle systems don't play:
    they play in Editor Simulation Mode, and they play in game if I use Play On Awake.

    In my script I use next code, initialization:
    Code (CSharp):
    1. _collisionParticles = transform.parent.FindChild("PlayerCollisionParticles").GetComponent<ParticleSystem>();
    To play I use this code:
    Code (CSharp):
    1. _collisionParticles.Play();
    And to stop:
    Code (CSharp):
    1. _collisionParticles.Stop();
    Also, while I log _collisionParticles.isPlaying before and after I notice, after Play() it logs true, but after Stop() it remains true - and in both states I don't see any emission.
     
  2. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    I made a test (zip in attach): I create new project in Unity 5.3, create default particle system and try to Play it via script - nothing happened.

    Could someone download project and try to reproduce problem? I thought, the problem in project upgrade from old format to new, but it looks like this is a permanent bug... I cannot google any similar problems with particles in 5.3, so it looks like only I have this problem.
     

    Attached Files:

  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    I was able to reproduce the problem (Unity 5.3.1p1). The odd thing is, if you call particlePlayInvoke() from Start() directly (not using Invoke) particles start playing. I thought maybe it's related to Invoke() and replaced it with a coroutine, but it has the same issue. So, my second thought would be it's not related to Invoke, but more an issue with ParticleSystem itself.

    As far as I know, they changed a lot of the particle system code in 5.3 and changes often come with new issues.

    I'd submit the test project you have as bug-report, along with a nice how to reproduce list/description.
     
  4. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    Thank you, I made a bug report: (Case 757461) ParticleSystem doesn't play
     
    yc960, Gburdeti and Peter77 like this.
  5. DenisM

    DenisM

    Joined:
    Dec 6, 2013
    Posts:
    62
    Same issue here. A dirty workaround to change "sumulation space" to "world". This will allow to play particle system from script and from editor.
     
    PhoenixRising1 and litebox like this.
  6. Denchyaknow

    Denchyaknow

    Joined:
    Aug 4, 2015
    Posts:
    31
    Same here been having alot of issues with trying to manage my texture sheet particles. For me they seems to be stuck playing reported by debug.log, and I have to launch Stop() multiple times to make it stop. A work around was to add into method that plays the system a little simulation code.

    public void PlayParticles(int i)
    {
    pSys.Simulate(1);
    pSys.Play();
    }

    guh seems really dirty I know but it works :(

    using 5.3.1p1
     
  7. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    Last edited: Dec 31, 2015
  8. Gburdeti

    Gburdeti

    Joined:
    Dec 23, 2015
    Posts:
    4
    Hi,

    I have the exact same issue.

    I call play() and stop() and nothing happens, but if I set the particle system to play on awake it runs fine. This is very frustrating. I hope this issue is fixed soon.

    Edit: Sometimes the particle system plays, but only sometimes.

    Edit 2: IsAlive seems to not work either.
     
    Last edited: Jan 3, 2016
  9. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    Make sure to report an official bug by making a demo in a fresh project and with the project opened, using the Help > Report a Bug... menu action.
     
  10. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    I already made bug report (Case 757461 ParticleSystem doesn't play), QA team say when they decide in which version they fix it they write to me back.
     
  11. skok

    skok

    Joined:
    Jul 13, 2015
    Posts:
    6
    I found out something very interesting: the particle system plays correctly if you add an empty subemitter.


    Which brings me to the following topic, because I tried to add a subemitter through code: you can not change the parameters of the partcle system at runtime.

    For example, the EmissionModule struct is exposed as property. Because a struct getter returns a value and not a reference, C# does not allow you to change the parameters directly, only through getting, changing and setting again. However, there is no public setter...

    UPDATE: it works even if you just enable the subemitter module, no need to add an empty subemitter.
     
    Last edited: Jan 4, 2016
  12. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    I got an e-mail yesterday that stated:
    Guess we can hope for an official fix soonish.
     
  13. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Yes it will make things run again, but with subemitter enabled, automatic culling is off. Which defeats the purpose of pooling the particle system since I use pooling to improve runtime performance. If I am going to do that might as well just instantiate on use and destroy afterwards. I cannot believe such a critical function broken and they did not instant hot fix this thing.
     
  14. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Not fixed in 5.3.1p2, disappoint.
     
    litebox likes this.
  15. Gburdeti

    Gburdeti

    Joined:
    Dec 23, 2015
    Posts:
    4
    Just to let you know that I posted a bug report about isPlaying() and isAlive() not working as it should. Got a reply that it was fixed in 5.4.
     
  16. litebox

    litebox

    Joined:
    Aug 29, 2011
    Posts:
    158
    I got e-mail from Unity's QA: "We have fixed this and problem should not appear in the upcoming patch release (5.3.2p1)"
     
  17. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    I'm on 5.3.2p2 and i'm still having a ton of issues just getting particle systems to play. Why is this so difficult, they've been broken forever.
     
  18. PhoenixRising1

    PhoenixRising1

    Joined:
    Sep 12, 2015
    Posts:
    488
    I wish I would have read this an hour ago - would have saved me a lot of sanity. Thanks a lot for the dirty fix. :)
     
  19. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697

    Yes, the dirty fix works. but I get a ton of errors now (that do not interupt play in editor tho).....


    At Play()...
     
  20. PhoenixRising1

    PhoenixRising1

    Joined:
    Sep 12, 2015
    Posts:
    488
    They'll fix it eventually I hope. Didn't run into those errors while testing myself. Are you confident it's due to the particles?
     
  21. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697

    100%


    Have not tested outside of unity. Hopefully it does not crash iOS,
     
  22. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    Did they fix this? Should I update unity (I want to work on my project and don't want to have to redownload unity unless this is working)
     
  23. Collywobbles

    Collywobbles

    Joined:
    Nov 10, 2014
    Posts:
    14
    This is still in issue in 5.5.2. I am having to use Simulate(1) before the Play() as mentioned above otherwise no particle effect appears.
     
  24. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    Emit() does not work properly either in 5.6.0.f3. When Simulation Space is set to Local, it works the first time Emit() is called. However, it stops working for the consecutive calls. Once Simulation Space is set to World, it works every time.
     
  25. reigota

    reigota

    Joined:
    Mar 23, 2010
    Posts:
    86
    5.6.0f3

    .Play() does not work IF prewarm is not true.

    Any workaround??
     
  26. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    fix this before implementing any thing new and fanzy.
     
  27. Eoghan

    Eoghan

    Joined:
    Jun 6, 2013
    Posts:
    80
    Sending a hello message from Unity 2017 - this bug still exists two years on.
     
    GameLover90 and danniefasho like this.
  28. djsegler

    djsegler

    Joined:
    Apr 20, 2016
    Posts:
    20
    I see this bug in 2017.2.f3.
     
  29. damnSimpleGames

    damnSimpleGames

    Joined:
    Oct 13, 2017
    Posts:
    13
    Same here, dissapointing as they said, the new Particle System is buggy.
     
  30. Leuki

    Leuki

    Joined:
    Feb 27, 2014
    Posts:
    130
    .Play() does work if prewarm is not true.. I have a particle system in my game and prewarm is off and my code works fine..

    Code (CSharp):
    1. ParticleSystem dust;
    2. public GameObject _particleHolder;
    3.  
    4. void Start ()
    5.     {
    6.         dust = _particleHolder.GetComponent<ParticleSystem>();
    7. }
    8.  
    9.  
    10. /// In one of my methods i call
    11.  
    12. _particleHolder.GetComponent<ParticleSystem>().Play();
    then Stop in another ..

    Code (CSharp):
    1. _particleHolder.GetComponent<ParticleSystem>().Stop();
     
  31. Leuki

    Leuki

    Joined:
    Feb 27, 2014
    Posts:
    130
    @litebox here you go.. Not tested but in theory it should work

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ParticlesTest : MonoBehaviour
    5. {
    6.     private ParticleSystem _collisionParticles;
    7.  
    8.     // Use this for initialization
    9.     void Start()
    10.     {
    11.         _collisionParticles = GetComponent<ParticleSystem>();
    12.  
    13.         Debug.Log("Start");
    14.  
    15.         Invoke("particlePlayInvoke", 2.5f);
    16.     }
    17.  
    18.     private void particlePlayInvoke()
    19.     {
    20.         Debug.Log("_collisionParticles.isPlaying before: " + _collisionParticles.isPlaying);
    21.  
    22.         _collisionParticles.GetComponent<ParticleSystem>().Play();
    23.  
    24.         Debug.Log("_collisionParticles.isPlaying after: " + _collisionParticles.isPlaying);
    25.     }
    26.  
    27.     // Update is called once per frame
    28.     void Update()
    29.     {
    30.  
    31.     }
    32. }
    33.  
    or if its atatched to an empty gameobject like mine is..

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ParticlesTest : MonoBehaviour
    5. {
    6.     ParticleSystem _collisionParticles;
    7.     public GameObject _particleHolder;
    8.  
    9.     // Use this for initialization
    10.     void Start()
    11.     {
    12.         _collisionParticles = _particleHolder.GetComponent<ParticleSystem>();
    13.  
    14.         Debug.Log("Start");
    15.  
    16.         Invoke("particlePlayInvoke", 2.5f);
    17.     }
    18.  
    19.     private void particlePlayInvoke()
    20.     {
    21.         Debug.Log("_particleHolder.isPlaying before: " + _particleHolder.isPlaying);
    22.  
    23.         _particleHolder.GetComponent<ParticleSystem>().Play();
    24.  
    25.         Debug.Log("_particleHolder.isPlaying after: " + _particleHolder.isPlaying);
    26.     }
    27.  
    28.     // Update is called once per frame
    29.     void Update()
    30.     {
    31.  
    32.     }
    33. }
    34.  
     
    Last edited: Dec 8, 2017
  32. Leuki

    Leuki

    Joined:
    Feb 27, 2014
    Posts:
    130
    WOW.. just realized this post was from 2015 :confused:
     
  33. michal990909

    michal990909

    Joined:
    Dec 15, 2017
    Posts:
    1
    I found the solution, and it's to simply change particle system name in script and then put it in inspector once again. Maybe it helped only me but maybe it's global solution :confused:
     
  34. ShyshyDai

    ShyshyDai

    Joined:
    Jun 27, 2017
    Posts:
    8
    Code (CSharp):
    1.         ps.Simulate(1,false,false);
    2.         ps.Play();
    I did it and it works, but only the parent and the children have no reaction. Anyone can help?
     
  35. shangkeyun

    shangkeyun

    Joined:
    Sep 4, 2018
    Posts:
    1
    I came across the same issue and solved it by querying the game object directly.

    Code (CSharp):
    1. var holder = GameObject.Find("ParticleSpawn");
    2. var particle = holder.GetComponentInChildren<ParticleSystem>();
    3. particle.Play();
     
    Tofu555 likes this.
  36. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Same issue on 2018.3.02f, my particle system doesn't play at all. "Play On Awake" has been checked, when I run the game, the particle system is still not emitting. I noticed that when I turned to scene view while still running the game, the particle started to emit. It looked like something were being updated when I took a look at the scene view. In my case, particle.Play() doesn't even work.
     
  37. paulindrome

    paulindrome

    Joined:
    Mar 10, 2018
    Posts:
    36
    Can confirm. Something's bugged.
    Play On Awake is checked. Prefab with ParticleSystem in question is alone in the scene. Calling Play(true) from script in either Awake(), Start(), OnEnable() or any other sort of remotely called (f.e. Setup()) method doesn't start it. Setting Simulation Space to World doesn't start it.

    It only starts once the GO has been disabled and reenabled at least once or when I switch from Game to Scene view and back.

    Also. ParticleSystems on a prefab that aren't set to PlayOnAwake DO for some reason play on awake once at game start.
     
  38. vimino

    vimino

    Joined:
    Oct 8, 2018
    Posts:
    1
    Had this bug on a Prefab with several Particle Systems in Unity 2018.3.2f1.
    playOnAwake was set to true and I tried many of the suggestions in this thread but only switching to the "Scene" tab was starting them.
    I eventually found that setting their Culling Mode to Always Simulate worked.
    Since the Particle Systems were outside of the Scene it makes sense but shouldn't Culling Mode: Automatic figure things out? This is probably bad in terms of performance!
    ParticleSystem_Bug.png
     
    Last edited: Jan 23, 2019
    Novack, recyclingriot and Elringus like this.
  39. diegodimap

    diegodimap

    Joined:
    Jun 4, 2017
    Posts:
    6
    Unity 2018.3.0f2 and the problem still there.

    used this code at Start() to solve:

    ParticleSystem ps = GetComponent<ParticleSystem>();
    ps.enableEmission = true;
    ps.Simulate(1);
    ps.Play();
     
    Novack, fatemea and atifmahmood29 like this.
  40. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Unity 2020.1.2f1
    Slightly tweaked code from @diegodimap above, still works as workaround. (Culling mode automatic, play on awake false, prewarm false).

    Code (CSharp):
    1. ps.Simulate(0.1f); // Hack to workaround Unity bug that wont play the particles.
    2. ps.Play(true); // True to play the children as well.
     
  41. dragana998

    dragana998

    Joined:
    Aug 18, 2021
    Posts:
    1
    This comment is from 2015. and this comment save me now! Thank you!!!
     
  42. kyxap

    kyxap

    Joined:
    Aug 20, 2021
    Posts:
    8
    Hm in my case ParticleSystem attached to the prefab for some reason did not play after object is being created. But in debugger it shows the object created and reference to my ParticleSystem. That how I've fixed it without using Simulate:
    Added to Start:
    Code (CSharp):
    1. explosionParticle = FindObjectOfType<ParticleSystem>();
    Now it works without issue
     
  43. AdamCWhite01

    AdamCWhite01

    Joined:
    Sep 23, 2021
    Posts:
    1
    I had the same issue. my problem was that I assigned the particle from the project folder rather than the particle in the hierarchy.
    Then you can just use nameOfParticle.Play();