After developing Level 2, I realised I needed a way to store the information about what abilities the player has unlocked from scene to scene. However, this cannot be done with the Player gameobject as that would cause the player to spawn in weird places from scene to scene.
To fix this I created a created a ‘Player Manager’ singleton that is preserved even when transitioning scenes:

DontDestroyOnLoad() prevents the PlayerManager from being destroyed when the scene it comes from is unloaded.
Singleton
A creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance.

This Player Manager script is then able to store key information about the player’s progression that needs to be stored regardless of scene. In this case, they are stored in the form of bools.
The playercontroller script is then able to check the value of these bools and then unlock the player’s abilities correspondingly:

This PlayerManager will have a lot of use-cases and will be vital to the game functioning as intended.

Leave a Reply