Hey developers! I have worked with ContentProvider Service for many different projects, however I am working on a fairly large game, unlike my other projects, so I have some new questions when loading the player in.
Loading Information related to the game:
I’m working on a loading screen that has the task of loading the following assets:
400 Decals
418 Image labels
83 Sounds
224 Animations
88 Particle Emitters
18 Beams
Note: we are still developing the game, so this is the minimum it will have to load, and will be expected to load more assets.
Now here is the questions I have:
If I have a decal that is loaded, and I clone that decal and use it elsewhere, will this new decal, with the same image be already preloaded. How about changing a pre existing decal to an image that was loaded before?
If Question 1 is true, should I filter out identical Assets when making the list to load, so the same asset isn’t loaded twice? Does it even matter if I do or not?
When loading huge amounts, is there any upper limit I should be worried about?
Will I be able to load all these assets on join without putting too much stress on the client?
A lot of these assets are required to be loaded beforehand, and the main reason is because of the frequent changes we have in our game. For example, We have images that animated, with frames, so each frame needs to be loaded (if they aren’t, then frames swap before they are ever loaded, choppy frames and not the nice clean animations). Now this wouldn’t be an issue, but all those frames need to be loaded beforehand, and there is quite a lot of them. While we can load them at different times, It would be the easiest to load them at the beginning, where we can allow proper time of yielding to load them.
Animations have a similar story where certain rigs can swap from 4 different animations in ~2 seconds. Now I will say that we load animations differently (as we load them via animator as required),
But we would rather have a longer load time then improper loading of items,.
Cloning a loaded asset shouldn’t require the engine to reload the asset, so yes. If you change a decal to an unloaded image, it will have to be loaded.
No reason to load assets twice, although ContentProvider is most likely optimized to ignore this issue anyways
No, but beware PreloadAsync yields until all assets are loaded. Give the user a way out if an asset fails to load (such as a skip loading button, but PreloadAsync will continue anyways if an asset fails to load). You can measure the total assets that require loading with the RequestQueueSize property
I believe this depends on how fast the client receives asset data to download - regardless, same solution as #3 - just give the user a way out if they can’t pass the loading screen
I see you gave this as a solution. The issue is I wanted to make something that waits for all players to load, as some games do. My game has cutscene, one being very early, so it needs everyone to be ready at the start. This is so everyone starts at the same place, and so everything is all good. Should I be worried about failure stopping this proccess? Or will reading these errors be ok, and there won’t be an infinite yield?
The issue is I wanted to make something that waits for all players to load, as some games do. My game has cutscene, one being very early, so its needs everyone to be ready at the start.
ContentProvider is mainly meant to preload assets upon joining an experience. There is no reason to use it to load assets after a player joins - they would then have to be loaded anyways, no? Makes the entire thing moot. That’s why you preload them as the player joins - so when you do need to use them, the client doesn’t have to load them for the first time.
If you need to validate loading on every individual player, you will need to utilize client-server communication; this could involve the use of a RemoteEvent or RemoteFunction to communicate when a player is finished loading. Unfortunately, ContentProvider provides no events for finishing a batch of assets, but you can tie an event to the RequestQueueSize property discussed earlier to monitor progress, and then communicate to the server that this player is done loading once that property is 0 (however, this number may fluctuate as the queue can change in size as gameplay naturally occurs).
Should I be worried about failure stopping this proccess? Or will reading these errors be ok, and there won’t be an infinite yield?
Again, ContentProvider yields (halts execution of the thread) until all assets in its batch are loaded. It does not stop loading if an asset fails; it simply skips that asset. If that particular asset has to be loaded, the GetAssetFetchStatus method can tell you if that asset has been successfully loaded. Read below (from docs):
If any of the assets fail to load, an error message appears in the output. The method itself will not error and it will continue executing until it has processed each requested instance or asset ID.
I see you gave this as a solution.
I think it’s good user QoL to provide a means to skip loading. This is just my opinion; no need to follow it.