I am trying to go to the next level in a platformer game upon collision with an object. Here is my increase level function:
public void IncreaseLevel()
{
if (currentLevel < highestLevel)
{
currentLevel++;
}
else
{
currentLevel = 1;
}
SceneManager.LoadScene("Level" + currentLevel);
}
and the collision check:
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "EndLevel")
{
IncreaseLevel();
}
}