0
\$\begingroup\$

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++;
}

}

\$\endgroup\$
  • \$\begingroup\$ 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 \$\endgroup\$ – DMGregory Mar 21 '18 at 2:59
  • \$\begingroup\$ Hm, I don't know how to do that. How to differentiate two triggers? \$\endgroup\$ – Wildfire Mar 21 '18 at 3:27
  • \$\begingroup\$ 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. \$\endgroup\$ – DMGregory Mar 21 '18 at 3:28
  • \$\begingroup\$ @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. \$\endgroup\$ – Wildfire Mar 21 '18 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.