How to get the correct material on Hit?

Hey guys,

i am currently working on the Bullet impact effects and sounds when hit physics materials. It works well on my Static Meshes that have only one Material. However, if i have Multiple Materials in my Meshes it only returns the First Material.
For Example, i have a Wall element with 2 Different Materials, Wood for the Wall itself and Glass for the windows. It would only return Wood.

How do i get the correct material when hitting with traces?
Like i said it works well with other Meshes that have only one Material. But if it has multiple Materials it returns just the first Material Element in the list i think…

You need multiple collision primitives for that. Visual materials are applied to visual mesh. RayCheck and similar functions operate on collision meshes, not visual meshes. You could try SimpleFromComplex collision, perhaps if the trace is done against actual geometry you will get individual physics materials assigned to visual materials.

I had to use the UseComplexCollisionAsSimple and for the Glass getting to work i had to check the DoubleSidedGeometry.
So thank you for putting me in the right direction :slight_smile:

Bahh, yeah I meant UseComplexCollisionAsSimple :smiley:

first of all Break Hit Result from LineTrace and get FaceIndex , Hit Component.
then you need function Get Material from Collision Face Index

you can get from it value (and name) of hit material, then just check all materials with the same name.
In the end you get material index of this static mesh, that you can change in the future.

1 Like