Collision Profile Name C++ // Help! Trace Hit Results wont show any custom collision profiles

Hi!
I added custom object channel in my project settings and set them as collision channel in my static mesh assets. Then i created SMFoliage Assets and set thier Static Mesh reference to that Static Meshes, i mentioned before, with that custom collision channel. In my code i do line traces, to check the actual location from Foliage Instances, to prevent overlappings when creating new instances. So Far So Good… BUT…
If I try to allocate that foliage instance wich was hit i just cant get any references…
The Object Channel is [] == “”;
The Collision Profile Name is after converting “custom” OR some of that default types like WorldStatic etc. but NONE of my custom channel is shown anywhere!
I couldnt find any hint for some kind of .ini Data, where eventually that custom channel get stored or similar…
I tryied to SET a custom Collision Profile Name to every Body Instance, when iterating and assigning my assets to a TMap and setting that UFoliageTypes to Folaige Actor BUT if i try to access any Body Instance from a HitResult, I get wrong references / memory addresses / pointer again and again… even after complete reset…
so…
How can I Set Collision Channel / Profiles, so that they are globally readable / accessable?
OR
How can i set custom Data like Flags or Tags to Static Meshes, because they are accessable walking from a HitResult… Then i could check, wich kind of foliage my trace hit!

This problem is one of my demons since i started with c++ and tbh im tired of looking for workarounds in that specific case because i dont have to… i mean i guess…
PLEASE HELP ME :cry: i cant be the first one encountering this bottlewreck!
king regards much love merry chrisler!

One option could be to create a UserAssetData class for the StaticMeshes (UAssetUserData) - they work similar to Tags/custom data…

1 Like

Foliage + Landscape Splines do not properly inherit/update their collision settings from the static mesh asset. The settings get independently serialized into the level/landscape, and the “Use Static Mesh Collision Settings” doesn’t function properly at all for splines.

If you change static mesh collision after placing foliage, existing foliage will not be updated to match even when it has the “Default” collision name set. There are some ancient “TODO”'s surrounding that code in engine, but it’s more complex to fix than it seems.

I’ve “fixed” this in the past by making a tool which iterates over all foliage + splines in a level before save/cook, and updates their collision settings to match the static mesh asset they’re using, and saves the level. It’s not clean, but sadly the only way I could workaround it.

1 Like

Thanks for your answers!
Well, I will try to create custom data to work with, this could get handy anyway but i really wondering why there is no clear answer to it… Maybe this whole foliage code is kinda chaotic and nobody wanna touch it again, since it once worked for them^^
If I got my soloution Ill post it, we are not the first and wont be the last, struggling with it.

So, I wanted to check that Foliage for any UserAssetData Container and discovered that small field “Component Class”…


So, I created a new Child Class of that FoliageInstancedStaticMeshComponent Class and set it as used Component Class in that Foliage.

After Initializing that Foliage Info, the specific Component gets created and is accessable. Before Initializing that Foliage Info, you will get a nullptr or similar, anyway u cant access the Component before Initializing the FoliageInfo. Now you can set anything you want inside that Child Class and access it in a HitResult from a line trace.

1 Like