How to destroy / hide a single particle?

I tried using ParticleSystem.SetParticles to change the lifetime of a particle, but it reset the other particles. Is there a way to simply destroy / hide / move one particle without resetting the system?

What exactly did you do? As with the old system, I would guess you first have to get all current particles with ParticleSystem.GetParticles, then remove the particle you want from that array somehow, and then reassign that new array back to the ParticleSystem (but read on).

In the old particle system (ParticleEmitter), instead of removing the particle physically from the array, it was enough to set its energy to 0. This way the ParticleEmitter will take care of the rest, recognize the particle als being dead/finished, and remove it itself from its internal particle array. I would assume you can do the same with Shuriken?

EDIT: I tested this now for myself. The Shuriken works the same as the old system, you can modify/remove/add individual particles.
BUT the API call to get the existing particles is just plain weird and stupid, I have no idea why anyone would program it in such a way: Instead of simply returning the particles array, which you then can modify, you must provide your own array, which is passed to GetParticles(). After this call returns, your particles array has been filled with the information of the existing ParticleSystem. This is completely unintuitive, and would probably be frowned upon and discouraged in any programming guide, to call a function “GetXXX”, but then have it modify an array you have to initialize and pass into it.

tl;dr: Try this example instead, it will work. Create a new ParticleSystem with default emission behaviour, and attach this script to it. (Note, when using the menu GameObject->CreateOther->ParticleSystem, the ParticleSystem will initially have an x=270 rotation, for whatever reason)

using UnityEngine;
using System.Collections;

public class ParticleSystemTest : MonoBehaviour {
    
    private ParticleSystem ps;
    
    void Start () {
        ps=GetComponent<ParticleSystem>();
    }
    
    void Update () {
        // initialize an array the size of our current particle count
        ParticleSystem.Particle[] particles=new ParticleSystem.Particle[ps.particleCount];

        // *pass* this array to GetParticles...
        int num=ps.GetParticles(particles);
        Debug.Log("Found "+num+" active particles.");
        for(int i=0;i<num;i++){
            if(particles*.position.z>5) // large local z: let particle drop down*

particles_.velocity-=Vector3.up0.1f;_
_if(particles.position.x>1) // positive x: make it red*
particles*.color=Color.red;*
if(particles*.position.x<-1) // negative x: make it die*
particles*.lifetime=0;*
}
// re-assign modified array
ps.SetParticles(particles,num);
}
}_

So the more I research this, the more I’m beginning to believe that it’s impossible to adjust the properties of a settled particle without the whole particle system starting the animation from scratch. If anyone could just confirm this that would be great. Then I can start investigating another option for my bouncing collectable coins…

If what you are trying to do is make a particle dissapear on collision with a player object, or any object for that matter it can be done. It seems like it would be inefficient to do it this way but I have seen no slowdown and I have done this with systems with many particles.

The difference here is that I am using a monobehavior, below I will call it MyParticleSystem, to copy the particle array into its own array every update. So every update I am using the behaviors ParticleSystem.Particle to Get and set the particles. This way I can expose the array and have access to modify it between updates without having to worry about doing a particleSystem.SetParticles() at an odd time risking some unwanted behavior.

If you get the collision event using OnParticleCollision on the Player character.

void OnParticleCollision(GameObject other)
	{
		ParticleSystem particleSystem = other.GetComponent<ParticleSystem>();
        MyParticleSystem mySystem = other.GetComponent<MyParticleSystem>();
        if(null != mySystem)
        {
                    //here we will get the particle list from the attached MyParticleSystem
			ParticleSystem.Particle[] points = mySystem.GetParticleList();

			ParticleSystem.CollisionEvent[] collisions = new ParticleSystem.CollisionEvent[particleSystem.safeCollisionEventSize];
			int numberOfCollisions = particleSystem.GetCollisionEvents(this.gameObject, collisions);
			int j = 0;    
			
			while(j < numberOfCollisions)
			{
                    //find the particle closest to the collision
				    Vector3 collisionLocation = collisions[j].intersection;
                    float closestDistanceToIntersect = float.MaxValue;
		                int closestParticleNumber = -1;
		                for(int i = 0; i < this.points.Length; i++)
		                {
                                ParticleSystem.Particle p = points*;*
  •                      float distanceFromIntersect = Vector3.Distance(p.position, collisionLocation);*
    
  •  	                if(distanceFromIntersect < closestDistanceToIntersect)*
    
  •  	                {*
    
  •  		                closestDistanceToIntersect = distanceFromIntersect;*
    
  •  		                closestParticleNumber = i;*
    
  •  	                }			*
    
  •                  }*
    

//I am pretty sure lifetime has to be set to less than 0.0f to get rid of it

points[closestParticleNumber].lifetime = -1;

}
//assign the list back to the object
mySystem.SetParticleList(points);
}
}
This works nicely for me. This is a much condensed version of what I use however. I am not saying it will work for systems with 2000+ particles I have tested with the upwards of 800-900 with no slowdown in a test environment. I found that if you dont use the behavior to keep track of the particle list then the OnParticleCollision script will have to use the particleSystem.GetParticles(particleArray[]) and particleSystem.SetParticles(particleArray[], arraylength). SetParticles will remove any particles with a lifetime < than 0 so if the collision script runs it can cause unwanted behavior sometimes.