# Activating particle system after 2 triggers on enter

I would like that

particle system must play indefinetely at some position after two triggers on collision are triggered on enter. When game starts, particle system is deactivated.

I have make this script where I can attach particle system into prefab and I have set spawnpoint position.

1) Is it possible to activate particle system differently (without Instantiate) ?

2) How to make that two triggers on enter activate particle system? One trigger is not enough.

using System.Collections;


using System.Collections.Generic; using UnityEngine;

using System.Collections;


using System.Collections.Generic; using UnityEngine;

public class spawn_object : MonoBehaviour {

public Transform spawnpoint;
public GameObject prefab;

public int i=1;
// Use this for initialization

while (if <=2)
{
void OnTriggerEnter () {

Instantiate (prefab, spawnpoint.position, spawnpoint.rotation);
}
i++;
}


}

• Have you tried including a variable that counts up with each trigger that enters? This seems like a fairly clear first step, so I'm wondering if you encountered any specific trouble with that we could help with – DMGregory Mar 21 '18 at 2:59
• Hm, I don't know how to do that. How to differentiate two triggers? – Wildfire Mar 21 '18 at 3:27
• Maybe with a comparison operator like == ? It sounds like you might want to work your way through some more basic tutorials and exercises to get a handle on the fundamentals of C# programming. – DMGregory Mar 21 '18 at 3:28
• @DMGregory I've changed the code but I don't know how to indentify both triggers. I should have something like trigger[1] and trigger[2]. I don't know how to pass the fucntion trigger[i] argument. – Wildfire Mar 21 '18 at 9:44