Hi everyone, I created a simple Blueprint on a StaticMeshActor to load Dynamic Meshes (sequences of meshes to form an animation). Running it in PIE mode works without issue, but when in its own process or packaged, SetStaticMesh always results in failure, and as a result the animation does not play.
DynamicMeshTick is triggered at a fixed 30 frames per second via delta calculations in Event Tick. The StaticMeshActor is set to Stationary mobility, and changing it to Movable did not fix it.
Thank you very much for any pointers you may have! I’m relatively new to UE so I appreciate it.
Sometimes dynamic assets if not referenced to build explicitly, does not go into the cook/build. Thus when this happens if it’s tried to be spawned from a script, it would result in failure/not visible object etc.
Just a simple test to see if that’s the issue:
You can set some of the meshes in level somewhere back that player doesn’t see and package again to see if they are being spawned.
If they spawn and your scripts work, you can define the meshes folder in Project->Builds packaging to make sure they are packaged as well.
This was, in fact, the real issue! I got the assets to load by adding the folder to the primary asset types to scan, in Game > Asset Manager rather.
Thank you very much!
While on the topic, is it possible to preload the associated materials? The meshes spawn in with a default grey until at least a full run-through of the animation, and even then the texture is clearly not fully loaded for a while. It’s possible working with meshes dynamically like this is maybe not the best solution in the first place, but it’s the only solution I had found so far.
First thing you can do for that material you can disable streaming . In material → disable texture streaming just to verify if that’s the issue.
The second one if you have soft references etc. even you don’t have them you can load these materials in your blueprint on begin play. So they are already loaded in memory, it’s like pre-warm meshes, you load them once before usage.
Right now you are basically loading and using at the same time, that’s why you see the grey / low quality for a while.
If you want a cleaner setup, you can use something like a streamable manager and wait for the OnLoaded event before starting the animation, so you guarantee everything is ready before showing it to the player, but not necessarily required if we are talking about 10 meshes.
It’s more along the lines of 200-300 meshes for the average dynamic mesh, so a different solution is preferable. I cannot feasibly modify every material by hand to disable streaming.
Can you please explain how I can implement that second solution you mentioned? I already iterate through the meshes in the BeginPlay part, so it should be easy enough to integrate into my existing BP:
That will make sure, they are loaded, this is effectively a prewarming, even doing this maybe on construction is better. So there is a time difference for materials to be ready ready before animations start.
There’s something I don’t quite understand here; The method you show preloads the material for a given Static Mesh Component, but I have a list of Static Meshes, not components. I could create a component for each mesh, but how would I then show them one at a time?
The way my BP works now is having a list of Meshes, and for those to be set to the one Mesh Component in order.
Thank you very much for all your help! This first solution works in the PIE, not yet in standalone but I’ll figure it out. Either way, all issues resolved for now.