ParticleSystem.Play() does not play particle

So, I have a Shuriken particle that works fine when I clicked Simulate button during the edit time. However, when I try to play this particle using particleSystemComponent.Play() via a C# code, it does not emit any particle. Using a debug log, I found out that

  • particleSystemComponent.time is always at 0.
  • particleSystemComponent.particleCount is 0. (So, yeah, it did not emit any particle after Play() is called)
  • particleSystemComponent.isPlayed is true. (It is playing but the time is always at zero…why?)

Nevertheless, if I use particleSystemComponent.Emit(1); instead of particleSystemComponent.Play();, a single particle will be emitted and the time will start running until the particle ends and the time will stop again.

However, Emit(1) is not a proper way to spawn particle since it will not spawn a correct series of particle. Is there any solution to make the Play() method working?
Thank you for your suggestion.

Had a similar problem. I think the problem is if you ever call Play() or Stop() without checking if it is playing already.

pS.Play();
...
pS.Stop();
...
pS.Stop();
...
pS.Play();

Caused the Particle System to start running again but not emitting particles if for some reason. With … I mean that other code was executed and the functions where called in different updates!!

The following code does restart the emission:

if(!pS.isPlaying) pS.Play();
...
if(pS.isPlaying) pS.Stop();
...
if(pS.isPlaying) pS.Stop();
...
if(!pS.isPlaying) pS.Play();

Almost a year old this post i know, but I had the same thing. I couldn’t work out why it wouldn’t emit, the only way i could make it work was just to have PlayOnStart ☑ checked, and the object inactive, then set active later (particleSystemObject.SetActive(true);) and it works fine:

Hope this helps, sorry for the years wait :wink:

Thank goodness for the forums, the documentation is lacking sometimes.
I did similar what was done here, but more brute forced.

void Start () 
{ 
   _particle00 = GetComponent<ParticleSystem>();
}

void SFX ()
{
    _particle00.Stop();
    _particle00.Play();
}

Hope this helps someone out there.
Sharin’ is carin’
@indiedoroid

Make a Particle System and attach this code along with it:

void Start()
{
     ParticleSystem pS = GetComponent<ParticleSystem>();
     pS.enableEmission = true;
}

I had the same problem. What was more confusing is that the particle system that wasn’t working was duplicated from one that WAS working. I logged .isPlaying before/after .Play().

it logged false.
it logged true.

Yet it wouldn’t render, no idea why. Anyway, i moved it’s place in the hierarchy, then moved it back again… suddenly it worked fine.

Still not works, actually, when I want my virus to spawn I want an explosion to occur, soo, code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VirusSpawner : MonoBehaviour
{
	public Transform[] spawnPoints;    
	public GameObject virus_Prefab;

	public float spawnTime;
	public float spawnDelay;

	public ParticleSystem virusSpawn_FX;

	void Start()  // Real magic
    {
		InvokeRepeating("SpawnVirus", spawnTime, spawnDelay);
    }

	// Functions
	void SpawnVirus()  // Spawns a virus
	{
		foreach(Transform spawnPoint in spawnPoints)
		{
			GameObject virus = Instantiate(virus_Prefab, spawnPoint.position,
				Quaternion.identity);

			if(!virusSpawn_FX.isPlaying)
				virusSpawn_FX.Play();
			if(virusSpawn_FX.isPlaying)
				virusSpawn_FX.Stop();
		}
	}

	IEnumerator Wait(float time)  // Timer
	{
		yield return new WaitForSecondsRealtime(time);
	}
}
Running Unity-5-4

I had this same problem. I created a new GameObjectParticle System. It worked fine when in the Hierarchy with Looping set.

When I dropped the Particle System into another GameObject it failed to play when I called this code:

var exp = GetComponent<ParticleSystem>();
exp.Play();

When I created a new Particle System in that same GameObject using the AddComponent button .Play() worked just fine:

GetComponent<ParticleSystem>().Play();

@mandinga90 I had this same problem but when I used ps.Play() in Start it worked but not in Update(). Therefore I think that it is not a bug but a feature.

A recall of Play() restarts the cycle before the emissions have got out of the starting blocks. So the check it was playing before calling Play() worked for me.

I had the same problem after experimenting a lot I found-
Connecting the particle system first with the game object and then dragging into (serializefield) where you set the particleSystem makes it work perfectly fine.

This answer may not help (at least for 3d games), but I had the same problem and thought that the Particle System was broken.

Then I realized that when creating a new Particle System, it was created on the z axis with -50. I moved it close to the camera and DONE. Being so far from the camera, I couldn’t see it.

Made an extension class that builds on TB_BSGs solution

public static class ExtendedParticleSystem
{
    public static void SetEmitting(this ParticleSystem particleSystem, bool emitting)
    {
        ParticleSystem.EmissionModule emission = particleSystem.emission;
        emission.enabled = emitting;
    }

    public static void SafeStop(this ParticleSystem particleSystem)
    {
        if (particleSystem.isPlaying) particleSystem.Stop();
    }

    public static void SafePlay(this ParticleSystem particleSystem)
    {
        if (!particleSystem.isPlaying) particleSystem.Play();
    }
}

So you could now call

particleSystem.SafeStop()

Instead of

if (particleSystem.isPlaying) particleSystem.Stop()

Same for Play()