Problem with scoring on scenes change from "Game" to "Game Over"

Hello !
I have a trouble with the scoring.
Till the game, everything works fine (on the “Game” scene).
But when it goes to the “Game Over” scene my score is always 0.
I checked the code a few times, it’s correct.
I think the trouble is in the hierarchy of the objects.

Please help me.

6 7

I would put some print statements in your code to make sure your game session isn’t getting lost and replaced with a new one. Can I see your game session code? Is the game over score text hooked up with the game session?

In your Level script in the LoadGameOver method; you’re calling ResetGame which looks like it destroys the current game session.

It happened the same to us. What we think is the problem is that you are looking for GameSession on Start so it gives you the new gameSession(the one that will be destroyed by the gameSession of the previous scene). If you put gameSession = FindObjectOfType(); in the Update it should work.
It is much more inneficient and we don’t think it’s the best solution so if someone from GameDev knows better, we will be glad to know the proper answer. (Sry for the english)

1 Like

This topic was automatically closed after 5 days. New replies are no longer allowed.

Privacy & Terms