Crash particle effect does not play

I was able to do the finish line without any problem and my Debug.Log() message for the crash works fine, but the particle effect doesn’t play. It also doesn’t play the particle effect in the editor, but it used to. Not sure what might have changed.

Here is the code to trigger it:
public class CrashDetector : MonoBehaviour
{
[SerializeField]
float delayTime = 1f;
[SerializeField]
ParticleSystem crashEffect;

/***
* OnTriggerEnter2D is used to detect when the players head hits the snow.
***/
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag(“Ground”))
{
Debug.Log(“Ouch, hit my head!”);
crashEffect.gameObject.SetActive(true);
crashEffect.Play();
crashEffect.gameObject.SetActive(false);
Invoke(“ReloadScene”, delayTime);
} // if
else
{
Debug.Log("Contact with " + collision.tag);
} // else
} // OnTriggerEnter2D(Collider2D collision)

/***
*       ReloadScene is used to restart the level, but called after a delay.
***/
private void ReloadScene()
{
    SceneManager.LoadScene(0);
}   // ReloadScene()

} // class CrashDetector

Everything works except for playting the particle system. Any suggestions as to where I can look for a cause?

Thanks.

Mike

Hi,

Good job so far! :slight_smile:

Particle System components work on active game objects only. For testing purposes, comment out crashEffect.gameObject.SetActive(false); to see if the particles get emitted.


See also:

Privacy & Terms