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