what I’m trying to do is I try to create an RPG style game which when the player encounters an enemy on the field, the scene is switched to the battle scene while pausing and maintaining everything in the scene (ie. the position of the player, current health, etc). Then after the battle, the game scene is reloaded and everything turns the way they are before the battle. Is there a way to do this?
DoNotDestroy() I believe is your answer?
edit.
This alone probably isn’t the best way. You could either save the state of the previous scene, load the battle scene, and then reload the previous scene using the saved data (the methods for doing this are numerous) or use LoadLevelAdditive to load the battle scene and then destroy all the objects in that scene when the battle is over.
Create a separate script to store variables - use that to maintain health, etc. Don’t attach it to an object - use it as a database and refer to it as needed from any scene. If a variable is changed - it’s not scene dependent, its project dependent.
Separate by classes/functions. Then call those whenever you wish.
As KelsoMRK said, I’m thinking LoadLevelAdditive/LoadLevelAdditiveAsync is an option too as long as you have a reference to everything that is added when the scene loads, and then Destroy() it when the scene is done.