extinguish fire

i’m making an firefighter game where the goal is to extinguish all the fires in a building.
i have managed to be able to shoot water walk and stuff.
buy how do i make it that i need to shoot the particle(which i attach to an invisible cube)
for 3 seconds it deletes and the fire stops.


The easiest way would be to use the legacy particle system, so you can add collision detection to the particles.

Set up your particle emitters that will represent the fire hose object emitting water particles and all of the flammable objects emitting fire particles. The legacy system requires you to add a particle emitter, a particle animator, and a particle renderer to the objects (See the menu Components->Effects->Legacy Particles). It doesn’t use a separate GameObject particle system.

Add the World Particle Collider component to the fire hose object and check the “Send Collision Message” box in the inspector. This will let you use the collision in a script.

Next you will need to add a script to the flammable objects you created. I know C# better than javascript so this is in C#. Add the OnParticleCOllision function to the script. In side here you can create a counter that tracks all of the particles that have hit and if it reaches a certain number than you can turn the fire emitter off. In the Update function you can decrease the counter. Think of it like the fires health bar.

public class Flamable : MonoBehaviour {
	public float FireHealth = 50;
	public float MaxFireHealth = 50;
	public float HealthRegen = 5;
	public bool IsOnFire = true;
	void OnParticleCollision(GameObject other) {		
		if(IsOnFire) {
			FireHealth -= 1.0f;
			if (FireHealth <= 0) {
				IsOnFire = false;
				transform.GetComponent<ParticleEmitter>().emit = false;
				// other things to do when fire goes out
	void Update() {
		if (IsOnFire) {
			FireHealth += Time.deltaTime * HealthRegen;	
			if (FireHealth > MaxFireHealth) {
				FireHealth = MaxFireHealth;

Take a look at the this question for some additional details for the particle system