Hello!
We are creating avatars for Metaverse (avatarsdk.com), and we usually need to load avatars at runtime to a scene. E.g it is required for AR\VR conferences when we need to add a new unique avatar for a new participant.
We are trying to load an avatar skeletal mesh model with blendshapes set at runtime in UE 4.26. To accomplish this task, we create and initialize an instance of USkeletalMesh. We call USkeletalMesh->RegisterMorphTarget for each blendshape and USkeletalMesh->PostLoad() after that. While the resulting model looks good and the morph targets work fine, we do experience a noticeable freeze (~0.5-1 second) while PostLoad is running. This freeze does not occur (or is not noticeable) unless we add any morph targets. Due to USkeletalMesh->PostLoad() limitations, it can only be called on the game thread. So loading multiple models at runtime can lead to a terrible user experience for projects like the metaverse or any software that requires runtime avatars to be generated. Is there a way to solve this problem? Are we using the right tools to solve our issue?
Thereās no way you can load this asynchronously?
No, because USkeletalMesh->PostLoad() works only in game thread.
Youāre absolutely sure that you canāt use this?
Yes. Let me elaborate: this article describes loading assets, but models we need to load may not even exist at time the application starts. An avatar model may be generated later and we need to display it at runtime. Procedural mesh could be a solution but it doesnāt support skeletal animations and the performance is also a question.
You can load new assets at runtime:
This is code I made that loads user-added sounds at runtime and plays a random one:
Assets can even be added to the game directory at runtime (i.e. they donāt need to exist at game startup).
Thanks a lot, Iāll take a look
Yep it really works. At first had problem with filter (search returned nothing) but removing the empty parameter arrays/sets solves it. Now I wonder if it is possible to generate .uasset files without working Editor instance. Letās say if I have skeletal mesh already loaded in UE shipped app, is there any way to export it to the disk?
I have no idea, but a very quick skim through the source docs makes me think maybe, but youād have to look into that.
If you mean like for downloading another userās avatar, then you could probably just send the .uasset file itself to the user rather than exporting from the game.
Surely the uassets get packed during .exe packaging?
You can package a game without the assets getting packaged into a pak. But you could probably get away with just copying the usassets straight from the project (like in asset migration).
Yes, this is the hard thing: now I need a way to generate uassets from source 3d-model to wrap it later into .pak. As for now my experiments show there is no way to do that without running instance of Editor. If the uasset is generated, we can copy it from the project.
Thereās FPakFile | Unreal Engine Documentation, which is in the runtime module, so may be usable at runtime, but I donāt know. But if youāre trying to keep users from copying the model from the game directory, there are still programs that can open .pak files, so you may need more.
This is for WAV files only, correct?
No, thatās just what I decided to filter for (and SoundWave refers to the class, not the file type). You can get any & all assets if you want. You can use Get Assets by Path to get all in a path.
So Get Assets by Path would only return files imported in that folder, or does it just return any file in there?
It returns all asset files in a folder or subfolders, i.e. .uassets, not .wav, .mp3, etc.
And I just realized youāre looking for regular file types, not .uassets, right? In that case, you will probably need to do it C++. I think thereās a file āfinderā or something like that, but Iāve never used it, Iāve only used plugins for stuff like that.
This is in blueprints: Find Files (and more in File Utils). I think you have to enable a plugin, though, but itās built-in.
I didnāt find it in mine, but itās probably cuz Iām on an older version.
Can this method load uassets from someone elseās Unreal Engine project?
I want my end users to be able to create a new unreal engine project, then import their custom skeletal mesh armor or clothing based on my gameās base character nude model. Then they can copy their generated uassetās into my gameās GameUserContent folder. Then I use your code to load their custom armor onto my characters model. Would that work?
/GameUserContent
skMesh_Clothing_MadeByBob_InHisOwnUEProject.uasset
skMesh_Armor_MadeBySally_InHerOwnUEProject.uasset
Do uassets have unique ID or encryption that make them incompatible with other UE projects that try to use them?
@nsdfxela, did you ever figure this out for skeletal meshes?