Deactivating preload leads to error

Hi there !

I’m working on a project with multiple environments (like a city / or an amusement park), and select the correct environment at startup. If one environment is loaded, then there is no need to download the assets of the other environments.

In order to optimize the loading time and avoid downloading everything, I deactivated preload of every mesh that’s not shared between the environments, so that they are downloaded only when I activate the environment they belong to.

I am now facing an issue with entities that contain such non-preloaded assets and that have a collision component :

An example can be found here : PlayCanvas | HTML5 Game Engine

The issue stops the rest of the loading process and my project fails to launch.

Any ideas as to where that comes from ? :smiley:

Project is private.

Assuming you are using render assets for collision meshes, there’s an issue where you need to ensure the container that the render asset is referencing first.

The general practise is to load all your assets before loading the scene that they are being used in first.

Sorry about that, fixed it :smiley:

Could you please rephrase that ? I am not sure I understand what the issue is :slight_smile:

So if I understand right, unchecking preloading only makes sense when working with multiple scenes ? I cannot work with multiple scenes as I have a ton of logic that needs to be shared between them. Besides i do not know at first which environment to load, that is provided by API later on. It is way easier for me to have all my environments in one scene, and then enable / disable the entities once I got the response :confused:

In your case, you will have to load the assets before the entity hierarchy is enabled

I see… That is an issue for me as I’m supposed to develop more and more environments, and i cannot really afford to make everybody download all the meshes (even thoses they won’t need). Do you see a way I can do that differently ? :slight_smile:

edit : I’m thinking of the following solution :

Tagging all assets depending on what environment they belong to, and making sure I download them all using this : Preloading and Streaming | Learn PlayCanvas before I make the switch to the other environment. What do you think ?

You don’t have to download all the meshes, just the ones that you intend to enable at any point

Yep, this is what I’m suggesting.

1 Like