- Home /
RPG - Battle loading, Scene Management.
Good day,
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.
As always Thank you so much for your help,
You guys are awesome!
Answer by Ehnn · Jul 26, 2015 at 05:51 PM
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
Thanks for that, its basically the correct version of my #1. How would you handle the loading of battle scenes to make them as efficient as possible? $$anonymous$$y big concern is the load time between battle Scenes and the "world" or "campaign" scene. I wouldnt want the player to experience more then a few seconds of "wait time" which I can hide by some transit screen/music.
Haven't delved into this one, I imagine there aren't a lot of easy solutions. Here's my guess at it
But first - Before going into these things, we should make sure there actually is a problem, the loading might take less than 3 seconds. No point prematurely optimizing
Scenes, in my experience, load pretty fast. It's not surprising, because even if we wrote a lot of code in them it won't run until after it's loaded. So the main thing (that I can think of) that would slow down the loading is either
Un-loading huge references from the current scene. Lets say we have a gameobject that references a bunch of 2048x2048 textures, that could take some time. $$anonymous$$ore suspicious points would be referenced 3D models, large images, huge text files, etc
Loading huge references from the scene we want to load - Same deal here, avoid 2048x2048 textures/images, 3D models, etc
Lastly, a lot of making games is smoke and mirror tricks. I know for my game there's a loading splash screen with text, and then once the scene loads, it usually stutters for a moment, so a fade-in to hide that
Are there any good tutorials that would go over how to do something like this or something similar to this?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Load all scenes on begning.... 1 Answer
How to have the scene load after a few seconds 1 Answer
Generating a preview for a scene. 0 Answers
Does Active/Inactive and Enabled/Disabled save memory? 1 Answer