Change Material Element When Clicked On

Hello, I’m currently wrestling with a problem in UE4. Basically what I want is for an object to change material when it’s clicked on. I have this working at present, however my static mesh is made of several material elements and I want to be able to have only the material element that the player clicked on change material. Any advice on how to begin this would be highly appreciated.

I’m still kind of new with blueprints, but maybe this would help. Since each material has it’s own index, you could try a hit event along with get material. Have the element index associated to the clicked part of the object. In other words, you may need to get mouse world location, perform a test to see if it clicks on that area, then get the material, followed by set the material to the new one. If I’m wrong on this, someone will likely say so. I have done something similar to this at some point I think.

Hi there,

Is this what you want? :slight_smile:

https://www.youtube.com/watch?v=RkJT…ature=youtu.be

First step for me was to create a cube in blender (used the basic one) and apply a different material to each side (6 material slots in total). After that I exported .fbx to unreal. Added collision to the static mesh but it didn’t work at intented (changed the material on wrong side). Took me a while to figure out it had something to do with LOD secion inside the static mesh. I don’t really know anything about LOD’s yet but I just started changing things over until I got the right result. I attached some screenshot, this is the exact setup I am using right now.

My naming can be a bit weird as I had to shuffle things around a bit. Let me know if something isn’t clear and if you want I can provide the static mesh and materials too.

Wow, that’s exactly what I was hoping to achieve and it works perfectly! Thank you so much!

Happy to help :slight_smile: