I have hundreds of objects that are collectibles in my game and i destroy them when collected. However, how do i keep track of which has been collected between scenes and destroy them again? Also, i’m using photon pun which may make this more difficult. I’ve tried using PlayerPrefs and it worked but with hundreds of objects it’s very unoptimised and brings lots of lag.
Anyone have any ideas?
PlayerPrefs is indeed not good for storing large amounts of data.
Generally speaking, a GameObject is mainly a container for both visuals and data. That data could be a MonoBehaviour that records the collectible’s data (eg health, armor, cost, and so on). More commonly devs will have a ScriptableObject that holds the immutable base stats. Or even load this from file (eg json) or a database (eg Sqlite).
My object purely adds on to a counter on the player and is destroyed (both done from the player pickup script), how would i go about storing it as a scriptable? And how would i save which of these scriptables are destroyed ? i haven’t used them before so not a clue.