Creating Singleton prevent gameSpeed to change from Scene to Scene

In previous courses we learned to change/adjust at the beginning of the level the gameSpeed so the ball can go faster on new levels. But since we implemented our singleton to keep score from scene to scene it also keep the gameSpeed from the previous scene.

How can we now change gameSpeed to be different on the next scene and keep our score ?

Hope i’m clear on the problem.

Thnx !

Dave

2 Likes

Hello, I thought about the same thing after watching the lecture. I believe the solution to that problem is to create a new Empty GameObject (call it something like GameSpeed) and add a new script to it, then remove the gameSpeed from GameStatus script and add it to the new script. So our points will continue to add in each scene but gameSpeed will be seperate.

You could also consider using the Scene Manager’s sceneLoaded event and wire up a delegate to it.

By doing so you can have a method with your GameSession called when any scene loads. Within this, you could reset the game speed or anything else that needs to be reset each level.

I had the same thought and decided to move it to the level object (which I call LevelLogic, it is just Level in the tutorial) as it contains settings and other details for the specific level. Which in my mind included the game speed.

I see you posted this a month ago, how did you decide to fix the bug?

Brett

Privacy & Terms