Spawning loot only the first time a level is loaded
I am making a 2d survival horror game in C# using the unity engine. The framework for the game is finished, and now I'm working on save mechanics. As you go through the game loot spawns randomly in things like desks chests etc... However, if you save the game mid-level, and load it up again later all of the loot re-spawns. How can I make it so the loot will only generate the first time a level is loaded?
Answer by Rob2309 · Aug 09, 2016 at 07:47 PM
There are many possible approaches to this problem:
You might just write the information about which items were already spawned into a normal file on the hard drive
PlayerPrefs could be a possible solution (Documentation)
If you only need to store the information for one session and don't need it when the program is started the next time, you could just use static fields in a C# class
Your answer
Follow this Question
Related Questions
Saving/loading inherited class scripts (C#) 1 Answer
BinaryFormatter - Save and Load lists of data? 0 Answers
Waiting for Saving/Loading? 2 Answers
Saving and loading an int variable on Android 1 Answer
Save and load whole scene 2 Answers