Weird behavior when loading levels using triggers.
So I'm trying to make a 2D game similar to The World's Hardest Game. However, I'm having a hard time making the level loading mechanism due to a weird bug that's happening. The way I load a new level is when the player touches one of the end trigger blocks. I have a function on my player object which will make sure to switch scenes (I'm using scenes to load levels) and add 1 to the level counter. And this results in my game loading and unloading my first level (scene index 0), all while the level counter starts giving me errors due to the fact that I have only put 2 levels into the game so far. Here is my player controller script, the only script that I am using at the moment:
I am baffled as to why this code is behaving this way.
P.S. also i used a pastebin link because the code was popping up weird when i copypasted it
Your answer
Follow this Question
Related Questions
How to unload a level after leaving a trigger area? 1 Answer
Trigger on two static players (collider 2D) 0 Answers
Multiple Entrances to levels 0 Answers
Calling Input from another script 3 Answers