- Home /
Best practice for storing objects
I've been developing a game for a while now (I'm experienced with Unity) and it has gotten complex enough where I need to take a step back and make sure I'm using efficient practices before it gets any larger. Here is a brief rundown of what is going on and what I'm trying to do (I've attached an example image): 1) This is a 2D Isometric RPG game. 2) When the player collides with an enemy in the overworld, a new scene is loaded and a battle takes place. 3) When the battle ends, the player returns to the previous scene to continue exploring
I've started looking into object pooling & other methods for handling this, but I'm not sure how to go about it yet.
What I need: - There is 1 player party and an undetermined amount of enemy parties. - When a scene is loaded, the enemies in that scene should appear - When you leave a scene, the state of the scene should be saved, including the enemy objects within it (e.g. if you killed an enemy it should not respawn next time you enter the scene)
What is the most efficient way to do this? Pool objects? Is it too memory in-efficient to store all possible enemy gameobjects and simply activate them when needed?
How big are your battle scenes? $$anonymous$$aybe you could just load them additively and disable the main scene until you return to it.
Answer by cgraf1 · May 30, 2017 at 09:21 PM
It sounds to me like after you kill an enemy, you could do a PlayerPrefs.Save() after destroying the enemy object
Your answer
![](https://koobas.hobune.stream/wayback/20220612123037im_/https://answers.unity.com/themes/thub/images/avi.jpg)