I am trying to find the best way to manage RPG Battle scenes for my game, currently I have a main game using a 3d interactive map and a 2d battle interface. My options that I currently thought of are as follows;
Create a new scene, store the reference positions of my character and gameobjects within former scene. When battle is completed, reset playerposition based on old position. This unfortunatly has additional load times between battles that could be unacceptable. (I have not tested the scene load but previously Ive had scenes take even half a minute to load.) there may be a way to optimize the loading of a scene if so I would be very happy to learn.
-or-
Create battle scenes within same worldmap being used but out of camera view (i.e at z=100). When a battle is engaged I disable current playercontrols and current camera view and activate a new 2d character/camera set. Once battle is completed I reactivate the world player and reset the battle scene in preparation of next battle.
I am leaning towards the second option (even though it will require more gameobjects within a scene and therefor reduce performance. I am unsure of any unforseen bugs or issues dealing with this.
Please let me know if there is a better or more standard way with dealing with these types of game within a game events.
**Note I do not have Unity Pro for any pro features that would solve this. i.e Aysync loading.
here’s another option similar to #1, let’s call it option #3
Have a data class that stores the state of the 3D interactive map: player positions, state of map locations, etc. Lets say this class is called MapStateData, or CampaignStateData if this is part of a campaign
Whenever a battle is entered, we save MapStateData in a way that is accessible regardless of scene (I like having it in a static variable. A file or PlayerPreference also works, depending on your situation), then we can completely un-load the current scene and load the battle one, access the data to initialize whatever we want in battle (if relevant), and at the end of the battle update the data with unit exp progression / whatever, and re-load the map scene once again using our data object
The advantages this offers don’t seem dramatic at first, but they make for very correct architecture which ends up saving a lot of headaches and time:
At some point in the project, we’ll likely want to serialize data, either to create save/load options, communicate over a network, or just for easier debugging, and saving all our relevant information in a data class will be very helpful there
It means we can completely unload and load scenes in unity. This is how unity is meant to be used and is generally good practice, for a bunch of reasons
It makes the different systems much more independent of each other, which is again good practice - one good example is that now if we want to load level 5 in the campaign with so-and-so data, we can tweak our data object and do it relatively easily and directly from the battle scene itself instead of awkwardly starting the entire campaign and getting to that point