The player object does interact with the obstacles, but the code that is supposed to be run is simply not working after the scene is reloaded.
Here is my reload code:
public void EndGame()
{
//code being run when player collides with an obstacle (works fine the first time)
if (!gameHasEnded)
{
gameHasEnded = true;
GameOverUI.SetActive(true);
Time.timeScale = 0f; //freezes the game
}
}
public void RestartScene()
{
StartCoroutine(LoadScene()));
gameHasEnded = false;
}
private IEnumerator LoadScene()
{
Time.timeScale = 1f; //unfreezes the game so the coroutine can work
float fadeTime = GetComponent<Fading>().BeginFade(1); //fades the scene out
GetComponent<DrawLine>().Reset(); //resets some lines the player has drawn
yield return new WaitForSeconds(fadeTime);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}