OK so basically I’ve created a simple box game with help from a YT tutorial.
All going well so far the one thing currently bugging out is:
The game only lets me play the first level (of 3) after pressing Restart before taking me back to the ‘win scene’.
I did a fraps vid so you can see what I mean:
2 main scripts below. Cheers!
2637466–185555–GameFunctionality.cs (546 Bytes)
2637466–185556–PlayerMovement.cs (1.36 KB)
Hi there. Instead of attaching the scripts you should insert them within the code tags in your post so people will be more willing to help you out, it may be a hassle for people to download and open the scripts instead of just looking at them here.
As to your issue it looks like you are incrementing your “scene to load” by 1 every time you complete a level which can work but now when you restart, the currentlevel is still 3 so when you hit Restart, which I bet your button is set to load scene 1, and finish that level, it’s going to load the 4th scene with is most likely your WinScene. You need to reset your currentlevel accordingly, or find another method to detect which level it should load. Hope this helps you out.
1 Like
Thanks for the tip i’ll bare it in mind.
I tried putting:
GameFunctionality.currentLevel = 1;
Inside this piece of code which is what the restart button calls.
public void GameRestart (int firstLevel)
{
SceneManager.LoadScene(firstLevel);
GameFunctionality.currentLevel = 1;
}
}
And it seems to work! Thanks again.
1 Like