Hello,
I cannot seem to find a way to get the material (or the material element index) from the break hit result, when the line trace hits an object that has multiple materials. I sometimes have a wall actor (one static mesh) that has multiple materials assigned to it (as that wall belongs to multiple rooms). But there is only a Phys Mat in the break hit result. This won’t help me, beacuse there is no way to get the actual rendering material from the Physical Material (that I am aware of). Even if there is a way to get the rendering material, there is little use of it because, in my pipeline (and I believe in many other peoples pipelines) I have one base material and I make instances of that base material to create other specific materials (metal, wood, plastic etc…). And the Physic material attaches only to base materials, not to instances (as far as I am aware of).
Other people have also asked for such feature, and here are a few posts that I’ve found:
Many of the solutions that are proposed in these threads are to make multiple actors of that one actor that has many materials applied to it. In this way there will be one material per object. So instead of having one object with multiple materials, there will be several smaller objects with just one material each. This is also not a viable solution, because this can cause serious light leaks to appear, when baking the lightmaps on those smaller objects that should be one monolithic object (that would be baked correctly). This way of working has more drawbacks such as:
- It is more time consuming to prepare the assets beforehand (that is to chop up the one solid object into smaller objects, so that each of those objects have only one material)
- Since there are more objects with one material, it is very unflexibile if in the future you decide to rearange the materials (to add or to remove some of the materials). This would mean that I have to reattach the smaller objects together, which in term means that I would need to readjust the UVs as well. And since I’ve changed the UVs, if I have hand painted textures on those UVs, I need to repaint the textures… and this whole pipeline as you can see, just keeps on getting more complicated…
That is why I’d like to request for the break hit result to have a material or at least material element index (as integer) output. So we can later edit or change the returned material of just that part of the object that the line trace hit. I’m sure that other people are interested in this feature.
Thanks