Load Asset : what does that node do exactly?

I have a feeling it’s used to pre load an asset to use later

It is the exact opposite. It is used to load assets at runtime (as opposed to on scene init). This way you aren’t hogging a bunch of RAM when your blueprints aren’t even using the asset yet. Im not sure whether the blueprint node is asynchronous or not. You can try it yourself. Find a massive asset and load it when you press a key, then do something with that asset. See whether the game hitches or not.

Edit: A use case would be that a player has a choice of buttons, and each one causes an item on a pedestal to appear. You don’t need to load both objects into memory - you only need the one that corresponds with the pushed button. In that case you would load the appropriate static mesh and spawn it on the pedestal.

I’m not very familiar with the concept of Asynchronous loading, what exactly does it do and when do we want to use it ?
I have a feeling it’s used to pre load an asset to use later, is that the case?

Thanks

Isn’t SpawnActor doing exactly that ?

Yes and no. SpawnActor creates an instance of an actor from assets that may or may not already be loaded in memory. When you create an actor using SpawnActor the actor needs to load its mesh into memory. You can’t use SpawnActor on a mesh - you need to load the mesh data from the disk if it is not already loaded.

SpawnActor creates an instance of an Actor and adds it to the level. The Load Asset node (whatever it is called) solely loads the object into RAM and makes it usable (makes a valid reference).

Oh ok i see now !

Thanks for the clarification, that will become handy in time of optimization.

That seems like kind of a weird example you give. Because in that example my logic tells me it would be better to in fact use a spawn actor node, as the object needs to be spawned anyway. Load asset is more for situations where you want to load something into memory as you say, but not yet have it spawned or part of the game world. It’s hard to find an example for this as in almost all the cases aI can think of spawn actor would be the better choice. But I assume it could be used for situations where you want to preload something or actually get a reference to a type of item that doesn’t actually need to be spawned. Maybe like an inventory item? I’m not sure, which is kind of why I’m still confused as to when to exactly use “load asset”. If anyone can give a good example that’d be wonderful.

This is my understanding:

Classes hard referenced in a blueprint graph (like using the drop down in the “Spawn Actor of Class” node) get loaded into memory when the blueprint gets loaded. So in Shohei’s example, you would be loading all three classes into memory before you even spawned anything.

The “Load Asset” node lets you load just the one class you need into memory, before you spawn it with “Spawn Actor of Class”.

There is a good explanation of this here.

Ok, given that the node “Async Load Asset” should be asynchronous (the clock icon on the right upper corner confirm that) it could be used to preload heavy assets in convenient moment of the game, right?
I also checked the Async Loading Thread checkbox in the project settings.

I made a test with an empy level containing just a cube with a color changing material so i can tell if it glitches, and pressing the spacebar i trigger 3 async asset loading nodes (here) with a very heavy mesh, a light one and a texture in decreasing size order: i should should see the print messages in reversed/mized orders.

Instead, the application freeze while loading the assets.

Am i doing something wrong?!

This is my understanding: Every Asset is a Serialized UObject, so when you use the “Load Asset” node, you de-serialize the .uasset file into a UObject. So when you use “Load Asset” on a blueprint, it is literally just loading the data for the blueprint object, not the class made by the blueprint object.

I think if you want to load the class any time you want, you need to use the “Load Class” nodes, and if you need to load an object (like StaticMesh, ParticleSystem, etc.) any time you want, you need to use the “Load Asset” node.