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?
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.
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?