Ball loads next scene when collding with lose collider

This may be later in the course but I have encountered an issue that when the ball goes out of bounds, the next scene loads rather than the game over. Interesting…

Unless I am missing and it should load. In that case, assistance would be great.

Hi Sahar,

What do you mean by “when the ball goes out of bounds”? The game over scene gets loaded if the ball collides with the lose collider or rather with a game object that has got a collider and our script attached which loads the game over scene.

If the ball moves around and triggers the “game over” unexpectedly, check if the aforementioned script is attached to other game objects but the lose collider.

i think I found the issue in the lose collider script as I had set the next scene in order rather than game over. I used a string reference for the time being for Game Over as a working solution.

Is there a better or more elegant way to do this (new to coding, so this all just trial and error!)

public Object GameOver;
private void OnTriggerEnter2D(Collider2D collision)
{
SceneManager.LoadScene(“Game Over”);
}

Does that mean you fixed the problem? :slight_smile:


See also:

1 Like

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

Privacy & Terms