Hey there
Im having a serious problem with load times on my map that is super heavy in static mesh foliage instances.
From all my testing I think I have found that It is being caused by the creation of the collision bodies for every instance, that I believe occurs when the map is loaded.
My map is covered in tens of millions of foliage instances generated by procedural foliage volumes. All of my foliage needs to be interacted with via different trace functions, so collision for my foliage has to be enabled. Collision for foliage is set to “query only” with overlaps disabled and all channels ignored.
When playing in the editor and in packaged builds with foliage collision enabled the load time of the map takes hours. Once the loading is complete everything runs fine due to optimization and culling of the foliage etc, but the load times are unacceptable.
However when collision is disabled, loading only takes seconds, for both playing in the editor and packaged builds. This is the same if I replace the procedurally generated foliage with landscape grass types. I believe it is because they also have no collision and are only created near the player on demand and not across the entire map.
I have tried loading the map with all foliage collision disabled and enabling it when its needed, but even enabling collision on a small fraction of foliage at runtime creates unbearable lag and stutters on the game thread.
I was under the impression that regardless of whether collision is enabled or not, the collision hulls/bodies would be loaded along with the static mesh instance they belong too and that enabling collision should be instant or near to it, but after doing a trace I don’t think that’s the case. In the trace I have found an event “createAllInstanceBodies” to be causing the stutters and long lag periods and I suspect this is the confirmation that when collision is enabled on foliageInstanceStaticMeshComponents, the collision hulls/bodies are generated, at least for the first time such as on map load anyway.
I can’t just load and unload foliage actors with world partition either. I need my foliage actors to always be loaded as I need my large trees to always be visible. I can’t HLOD the trees either as all foliage has to be able to be chopped down or removed at runtime.
I guess I’m wondering if anyone knows of a way to solve this long load time problem created by loading a map with lots of instances that have collision enabled? I would like to force it to happen asynchronously after the map has loaded to avoid the noticeable stutter and lag, or to be able to enable collision on only a small number of instances at a time when they’re near the player, but without collision hulls its hard to find a performant solution for that.
An interesting note is that procedural foliage generation is also much faster when my foliage instance collision is disabled, regardless of whether “collision with world” is enabled in the foliage type.
Also I have tested this in UE 4.27, UE 5.3, and UE 5.4 and I get the same results with all three engine versions.
EDIT: Attached is a screenshot of the trace
Thanks in advance to anyone that takes the time to read all that or reply.