Carrying player data between scenes in Unity (Pt.3, The Finale)
In my last two blog posts, I’ve been mentioning working on the same thing: getting player data to save and load in between scenes. At this point, the importance of getting it working and why it’s detrimental to the game if it’s not working is pretty well known. So instead, I jump straight into the explanation of my solution.
Over the past few weeks and after the many failures, I’ve managed to get player data fully saving properly in between scenes. On the surface, the solution is simple, at a certain point when the player is about to leave a level, have the run manager grab the necessary data from other places in the scene and then hold on to it between scenes. Because I made the run manager a singleton and made it not unload when moving between scenes, the data stays on the object and doesn’t get removed when a new scene is loaded.
However, that is only one half of the equation. What about loading the data afterwards? Well, after a lot of failed attempts, I got the player’s card data properly loading and the player’s inventory data mostly loading. Finding the right sources of information to not only pull from but to also send information into was a bit difficult as those weren’t my areas of work but after poking around and asking my teammates, I managed to get everything working, allowing the UI to be properly loaded with the player’s card data. As for the player’s inventory, the data does save to the run manager and it seems to partially load but the associated sprites for the items don’t appear in the inventory screen, along with the items almost being “ghosts”, with their corresponding slots getting overwritten when new items are picked up. I have a few ideas on how to fix this and hopefully, all the player data will be able to be freely used between scenes after this point.
Author: Gilbert Pemberton
Date: 5/3/2024
Get Suits of the Abyss
Suits of the Abyss
Status | In development |
Author | AstralArchitects |
Genre | Action, Platformer |
Tags | Roguelike |
More posts
- 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
- Carrying player data between scenes in UnityApr 13, 2024
- Poker Hand DetectionApr 13, 2024
Leave a comment
Log in with itch.io to leave a comment.