Carrying player data between scenes in Unity


When playing our game, the player has to go from scene to scene consistently but for the most part, the actual information that needs to be carried between scenes wasn’t able to be maintained and used, meaning information like what cards the player has and what other items they have, wasn’t being carried over. Another issue of this is that if we generated a seed for the system to use during the player’s current run, there was no guarantee that the seeded value would be the same in every scene. This is very problematic for the game as while we want randomness, we want reliable randomness that can be properly handled and organized so it can be utilized in a way that enhances the game experience instead of making it frustrating.


In order to fix this issue, I had considered a few different options, one of which being to just store all the information on the player themselves. However, that’s not the most efficient way of doing so as it would rely on a lot of objects and systems in the game being tied directly to the player or having to search for the player in the scene. It also doesn’t guarantee all the information being the same as in our project, the player is technically a bit different depending on the type of level they’re in, meaning different instances of the player are used.

The solution I finally landed on and had the most success with, was creating a manager system to not only store the necessary information for everything needed during a run (player items, run seed, etc.), but to also act as a central place for different systems and objects to reference and pull necessary information from. By creating the system and attaching it to an invisible object (one I’ve dubbed the god cylinder just for fun) that isn’t destroyed when loading a new scene, there will always be at least one up to date instance of the object in every scene that objects can pull information from, and by making it a singleton, it helps ensures that there is only ever one version of the information, preventing conflicts. There are still a few things to work out with the system but it’s mostly just in regard to how certain objects will use the information it gets from the manager and less an issue with the manager itself.

Author: Gilbert Pemberton
Date: 4/12/2024

Get Suits of the Abyss

Leave a comment

Log in with itch.io to leave a comment.