I stand before you, half alive, half dead, almost as if I have a lifecycle challenge
I had this idea of moving between scenes, originally I manually cleaned up all my mess in the same scene, but I found that I would miss things and performance would still dial down over time, so I figured an entire scene disposal and rebuild would be the right way to handle things.
I guess I’m struggling with the idea of the asset manager being tied to a specific scene. I know what I need to load in the background, and a lot of assets are shared between scenes, so it feels …not so optimal to keep creating new asset managers with largely the same assets in.
I might have missed this topic on the form somewhere, I did have a good scan, the lifecycle looks like:
Load what you know you need for the initial scene
Async load anything you don’t know or that is dynamically added to the scene
Async load assets for the next scene that you Might need.
I feel like I’m good on the first two, but the last one I can’t do, or I need to create a whole new scene and asset manager in the background to pull it off.
Have I got that right, and I think about things wrong? I did try creating an asset manager with a dummy scene, and that didn’t work out when it came to doing a instantiateModelsToScene.
Thank you, fellow scholars, for your wisdom
The AssetContainer is still tied to the idea of a scene through, so it wouldn’t enable sharing assets between scenes Hmmmm I wonder what would be the best solution for this, maybe @PatrickRyan has an idea?
Thats exactly it, @carolhmj , and thank you, @sebavan good suggestion; already using AssetContainers and that’s probably the challenge being tied back to a specific scene.
A totally fair answer would be, “you’re being lazy, write better code so you don’t need to tear down the entire scene and build a new one”.
Eh, your dedication to knowledge can never be classified as “lazy”, I think “how to manage shared assets between scenes” is a totally fair question. I don’t think there is a single answer to this, but studying the different approaches is always a good exercise.
You might get some scene management ideas from @jelster amazing Space Truckers repo jelster/space-truckers: A game of getting stuff from Point A to Point B… IN SPAAAACCE! (github.com) and the accompanying book too
All over it! thanks @carolhmj
@potato_noob, I don’t have a great answer for you here either because I feel the most seamless experience for the user is to maintain your asset container between sections/levels/areas of your game (I hesitate to use the word scene here because it’s a loaded term). If you dispose the scene to clear out all the garbage, you will need to load all your original assets into the asset container again which means the user is paying a load tax every time you need to refresh. This isn’t the best experience from the user’s standpoint and depending on their internet connection, you could be using up vital bandwidth for them which can leave a bad impression of the experience.
I would do everything possible not to reload any asset you’ve already loaded once if for no other reason than many people around the world have very poor internet speeds which creates a non-inclusive experience. In my area, fiber internet is common, but in my sibling’s area they need to rely on a 5G mobile hotspot for the house which is a simple illustration of why you don’t want to download any more than necessary.
In addition to the Space Trucker’s repo that @carolhmj mentioned, I would also suggest looking at the Dev Stories in our docs to see how they are handling any level change as well as The Space Pirates demo which is a far more complex version of loading assets and managing game state. There isn’t a lot of documentation around the Space Pirates demo, but all of the code and assets are there for you to play with. And if you have questions specifically around that demo, I am sure than @Cedric and @DarraghBurke can answer them as they wrote and/or optimized the code. Hope this helps.
browser cache? Any model you loaded once already is not loaded again in the same manner , the browser fetches it from the cache. ? am i missing something here.
Im also not convinced that you can infatically state doing a full reload is not a option and should be avoided like a plague. It honestly depends.
Engineering a battle tested system that hot reloads only essential code , data or assets can take magnitudes more time than simply building something that just reloads the lot and is only ever so slightly less ideal.
we talking small and medium applications here… If you building the worlds next greatest MMO game , yeah maybe then it makes sense , and even then , maybe not.