How do I spawn a sub-emitter without using burst?

PROBLEM:

I tried to use the sub-emitter module in particle system, but the only way to activate it is via the “burst” emission setting on the actual sub-emitting-particle-system.

This was very terrible for my use!

I have a flamethrower, and each particle that touches the ground needs to spawn a fire! But, using burst mode doesn’t allow the “fire” to propagate in the correct way. What I need is a way to Instantiate(fire) when the particle collides with the ground.

THE ANSWER:
There are many many complicated work-arounds and hacks online. After many hours of research into the topic, it appears that inside the particle system is the module: Triggers.

Inside of that module, You can clearly see that you can have the ability to interact with colliders set in the LIST.

The Downside is, that you have define which trigger colliders you want to interact with. Right, now, I just click the (+) and added the Terrain. Although, I am sure later, you might want to add a script which can automatically define all the different colliders you might have which we can collectively call “The World”

In my setup, this “FlameThrower” particle prefab will be instantiated when the player press the correct button. Because I don’t want a bunch of prefab references I also added the “Particle-GroundFire” as a child, but I disabled it. —>Picture Attached

[193507-flame-thrower.jpg*_|193507]

FIRST, we will adjust the Trigger module on the main particle system (In my case that is named “Particle-Flame”. So, after updating the LIST of colliders go down and set the Enter Trigger to “Callback”.

[193508-triggers.jpg*_|193508]

NEXT, I make sure this particular spell thingie, has a layer called “Spell-ToWorldOnly”, and then edit the project settings so that the physics truly only interacts between this spell-toWorldOnly and World (of which terrain is part of it).

NEXT, The when/what/why/how comes next! We will add trigger-script to the “Particle-Flame” which collides with my world, so that it know how to instantiate the object. The “when” is defined in the above mentioned trigger module of the main particle system.

Again, you can see now why I made the sub-emitter called “Particle-Groundfire” initially disabled. Because, I just want to drag it into the script inside of the editor window without referencing an additional prefab.

CREDIT must be given to the original Unity manual listed here as reference:

[Unity Manual: Particle Systems Trigger Module][3]

Here is my slightly modified script which is attached to the main particle system called: “Particle-Flame”

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

public class ParticleTrigger : MonoBehaviour
{

	public GameObject groundFire;
	private ParticleSystem ps;
	private List<ParticleSystem.Particle> enter = new List<ParticleSystem.Particle>();
	
	void OnEnable()
	{
		ps = GetComponent<ParticleSystem>();
		
	}

	void OnParticleTrigger()
	{
		// CODE WILL ALWAYS BE RUNNING CHECKING FOR TRIGGERS
		int numEnter = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);
		
		

		// iterate
		
		for (int i = 0; i < numEnter; i++)
		{
			ParticleSystem.Particle p = enter*;*
  •  	GoInstantiate(p.position);*
    
  •  	p.startColor = new Color32(255, 0, 0, 255);*
    

_ enter = p;_
* }*

* }*

* void GoInstantiate(Vector3 position)*
* {*
* GameObject tempObj = Instantiate(groundFire);*
* tempObj.SetActive(true);*
* tempObj.transform.SetParent(this.transform);*
* tempObj.transform.localPosition = position;*
* }*
}

_*
_*
_*[3]: https://docs.huihoo.com/unity/5.4/Documentation/en/Manual/PartSysTriggersModule.html*_

An easier approach that worked for me was to create a Sub-Emitter within a Sub-Emitter.

In my case, I am creating a particle effect for lasers being fired. When the lasers hit their target (i.e. die), they create a bullet hole. While the bullet hole exists, it emits a smoke effect. In the hierarchy, it looks like this:

LaserEmitter
    HoleEmitter
        SmokeEmitter

LaserEmitter has the Sub-Emitters section enabled, with HoleEmitter added on Death
HoleEmitter has the Sub-Emitters section enabled, with SmokeEmitter added on Birth

If you don’t need to render a middle Sub-Emitter (Hole), you can turn off its Renderer section.

Make sure the lifetime of the middle Sub-Emitter (Hole) is equal-or-greater-than the lifetime of the bottom Sub-Emitter (smoke)