Mobile Game with Infinite Levels, Remote Content
To keep it brief, just imagine Candy Crush Saga. There are potentially infinite levels, and many levels share assets and scripts, there are player and camera scripts that are the same throughout all levels, but each level can have different goals. Some assets are first introduced months or even years down the road. I'd like to know the best approach. My ideas thus far are:
the core game has all assets for the currently-available levels. Each level is a new scene and can obviously re-use all the assets at will.
The problem here is that when, say, 1,000 levels are created, I'd like for the player not to have to download all 1,000 levels at once nor all the myriad of assets at once He should just probably download the first 100 levels and all the relevant assets, and then when he reaches level 50, download the next 50 plus any new assets needed.
I'd like to be able to test each level quickly before publishing it to a server to be eventually downloaded.
I'd like to not have to update the core game every time new assets are introduced, but rather just check the server periodically for any new levels/assets that need to be downloaded.
I know it'll probably have to be done with AssetBundles, I'm just trying to figure out a workflow for developing and pushing levels/assets to my server for future download/integration.
One core question that might also help me on my way: when I compile a game, does it include all the assets in my assets folder, or only the ones that are instantiated in a scene or in code? Because if all are included, then I'd probably have to have one project for the main game with core functionality (player, camera, collision etc), and then a project for each level? When developing a level can I just use any asset I want, and then when I export it as an AssetBundle, somehow tell it not to export all the assets I have in the main game? What about new assets for the next set of levels (new goals, obstacles etc)? Can I export those separately one time and then have each scene know where to find them?
I also have no problems hiring someone as a consultant to help me get through this hurdle.
UPDATE: so far I've been able to create each level as a scene containing camera, light and player objects with the necessary scripts attached to make the level work. Then I have a prefab for the level, which includes:
a script with various settings such as time limit and score required to pass the level
all the obstacles and scenery for the level. They are all either built of existing prefabs or new entities (like a new terrain)
now all the prefabs for each level are at the moment already existing in the Resources folder, so they will be built with the game. In future, I'd probably have to keep all the prefabs outside the Resources folder so that I can add to them as time goes on.
I can successfully load each level as a prefab by loading first the core "game" scene, then adding the prefab of the level, assu$$anonymous$$g my level is in the Resources folder. I've been looking into saving the levels externally on a server and downloading them as AssetBundles, but it would seem that the AssetBundles also include all the child prefabs - even the ones already included in the Resources folder. So my thoughts are now that this way is not the right one. I now think that I have to try a new way:
Create an editor script to export each level scene with all the obstacles/settings into an X$$anonymous$$L or JSON file, which I will then keep on the server. (e.g.` { enemies: [ {prefab: "enemy1", position: {x:0,y:0,z:0}}, {prefab: "enemy2", position: {x:10,y:0,z:2}} ] }`)
All the re-usable prefabs will be stored using AssetBundles
I will keep tabs on which prefab AssetBundles the user has downloaded and which are necessary for the current level and download them when necessary
Each level will be loaded from the JSON/X$$anonymous$$L file and the downloaded/existing prefabs added to the scene at runtime
Does anyone see any problems with this or is there any tool get this process running more smoothly? Has anyone ever even tried this or does everyone just make the user download the game anew whenever there are new levels added?
Your answer
![](https://koobas.hobune.stream/wayback/20220612191818im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity remote 0 Answers
Asset Bundle error 0 Answers
Addressable Auto Updating Prefab? 0 Answers
Using mobiles as joysticks to control my game running on computer 0 Answers