- Home /
Retaining old scene data
Working on a proof of concept game which is spilt into two types of control, an FPS and a space simulator. I have the two setup in separate scenes and you can easily switch between the two on a click of a button.
My question is, I want to keep the positions of everything in those two scenes even if there not running, so if you run around as the FPS and switch- when you switch back you’ll be back standing where you were.
I’ve looked up some ways of doing this, but I’m still new at this and looking for the best way. Is there an easy way to retain the players position? And from there is there an easy way to retain the information of all the other objects in a scene? (Positions, damage, destroyed, etc).
Thanks
Answer by justinl · Sep 28, 2012 at 07:34 AM
You'll want to write a SaveState script that iterates through every object in your scene and records their data such as rotation, position, health, type of object before the scene is unloaded and the new scene starts.
Then, once you return to your scene, you'll need to iterate through this list and re-instantiate everything in your list and set them to where they were in the world, and to whatever action they were doing.
I'd recommend a List data structure to manage this list or you can roll your own Class that can hold this information.
Answer by Unity_gamer · Sep 28, 2012 at 09:44 AM
you can Try "Application.LoadLevelAdditive" as well . http://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevelAdditive.html
While Loading the next scene you can Manually delete the unwanted old Scene Contents.
Good luck..:)
Your answer
Follow this Question
Related Questions
enemy targeting player in different scene 1 Answer
Network - Load For Late Players 1 Answer
How to Make a cutscene? 3 Answers
Kill the Player? 1 Answer