"Game Over" scene not loading

I am unable to load “Game Over” scene on Unity. I guess my code is correct,too. No errors are displayed.

Here is the script

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

public class LoseCollider : MonoBehaviour
{

private void OnTriggerEvent2D(Collider2D collision)
{
    SceneManager.LoadScene("Game Over"); 
}

}

And here are Unity Screenshots:

Most likely the trigger is not triggering, put a print statement in the OnTriggerEnter and see if it comes up when you get a game over.

I tried that, too. However, it didnt show the print statement. But when i retyped the code, it worked. I’m just interested was my mistake

Hi Maksimjeet,

Is the issue fixed? If so, please mark a solution to close the thread.

Unfortunately, I was not able to spot any issue in your code snippet or your screenshots. Maybe there was an internal problem in Unity which got fixed when you retyped the code. That sometimes happens when Unity recompiles scripts.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms