How can I get the material under the cursor?

So I’m trying to develop a material switcher to allow us to switch through different materials within an architectural model.

I’d like to come up with a fairly general system to do this, and the first part of that is identifying a material to change.
I’m trying to get the exact material that a user clicks on, but I can’t see a way to get the exact material, since FHitResult only tells me the actor or component, which (As far as I can tell) could have multiple materials applied to them.

Is there a relatively simple way to find what material I’ve clicked on? Or would it require some overly complex analysis of the actor/component?

Sadly, there is no easy way to do this that I know of and you’ll probably have to dive fairly deeply into the source to achieve what you want.

At the moment, as you’ve noticed you can get the component, and you can get which materials are applied to that component. If you wanted more detailed information, you’d have to look at the mesh of the component and grab the relevant UV information for the verts you’ve hit, then get the corresponding material ID. For static meshes this should not be overly difficult (rigged skeletal meshes are an entirely different story, but mercifully this isn’t pertinent), but it will certainly require programming if there isn’t a nice little feature if it isn’t already there.

As a side note, if it isn’t there, this would be a nice thing to have exposed to the programmer / blueprint API.

Just as I feared :\ Well, I suppose if I can figure it out now I don’t have to again. Thanks for the help :slight_smile: