I am trying to use a GameManager script to store and hold my players points, across multiple levels. The problem is that I have no idea how I should implement this. Should I declare the points variable in the GM script (starting at 0 of course), and use the GM to read the point value from enemies and objects I interact with and add them as needed, or is there some other, better way to do this?


1 Answer 1


First, check out the discussion about implementing singletons for best practices on for creating a persistent script. I typically have my level controllers keep track of things like scores and other states and update the global game manager when saving or changing levels. I find this approach to be more flexible when building and testing individual levels, but your mileage may vary.

Another pattern to consider is a persistent scene (with a Game Manager script and little, if anything else) and with actual scene content handled by loading (and unloading) scenes on top of it in an additive manner. This has the advantage of being relatively easy to implement with Addressables and avoids the controversial singleton pattern.

layered scene loading

  • \$\begingroup\$ So basically a level controller will be implemented on a per level basis, to keep track of score etc,, and upon completing the level the game manager gets updated to carry over the score, and whatever other information I intend to keep persistent? \$\endgroup\$
    – TBG
    Commented Oct 7, 2021 at 15:10
  • \$\begingroup\$ Yes, I think that's a reasonable approach -- individual levels retain a certain amount of "autonomy" so they can be tested independently -- with a persistent globals singleton pattern you can have each level have its own copy of the global GM for testing, that could contain sane entry values for testing purposes, and when the game is played from the start or even a previous level that global GM is ignored -- again, see discussion re implementing persistent singletons... \$\endgroup\$ Commented Oct 7, 2021 at 15:17
  • \$\begingroup\$ Ok I will. Thank you for your help again! \$\endgroup\$
    – TBG
    Commented Oct 8, 2021 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .