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
Suits of the Abyss
Status | In development |
Author | AstralArchitects |
Genre | Action, Platformer |
Tags | Roguelike |
More posts
- Carrying player data between scenes in Unity (Pt.3, The Finale)May 04, 2024
- Player ground detection issueMay 02, 2024
- URP sprite shader issueApr 27, 2024
- Carrying player data between scenes in Unity (Pt.2)Apr 27, 2024
- Weapon Effects and AnimationsApr 27, 2024
- Resolution issuesApr 27, 2024
- Minimap and fog of warApr 20, 2024
- Player WeaponsApr 20, 2024
- Poker Hand DetectionApr 13, 2024
Leave a comment
Log in with itch.io to leave a comment.