0

I'm creating a turn based RPG and I want to save data between scenes. I've been using PlayerPrefs to do this however I want the data to be reset upon closing and re-opening the game again. The game goes between an "Overworld" scene and a "Battle" scene. I want to send all my characters stats from the overworld to the battle scene when a battle is commenced and I have been using PlayerPrefs to do so. However I don't want to permanently save the player stats as I want these to be determined by player level / Items and sent over to the battle scene. However the issue I've found is that when sending XP data back I would use PlayerPrefs aswell, Which wouldn't work as Id need to check this the moment the Overworld scene is loaded and if XP data is already in PlayerPrefs after a battle, that would mean the XP is added the moment the Overworld scene is loaded. So the player could just repeatedly open and close the game gaining infinite XP. Is there any other system to solve this?

HGBadger
  • 11
  • 3
  • 1
    Could use the [ScriptableObject approach](https://stackoverflow.com/questions/32306704/how-to-pass-data-and-references-between-scenes-in-unity/60408573#60408573) or just use some [static data storage or DontDestroyOnLoad singleton instance](https://stackoverflow.com/a/44542726/7111561) – derHugo Jul 31 '23 at 10:17
  • Alternatively just initially [reset all playerprefs](https://docs.unity3d.com/ScriptReference/PlayerPrefs.DeleteAll.html) when opening the game – derHugo Jul 31 '23 at 10:19

0 Answers0