Announcement

Collapse
No announcement yet.

Change Material Element When Clicked On

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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.

    Comment


      #3
      Hi there,

      Is this what you want?

      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.

      Click image for larger version  Name:	Lod-Slots.png Views:	1 Size:	92.9 KB ID:	1637665Click image for larger version  Name:	Trace1.png Views:	1 Size:	167.2 KB ID:	1637666Click image for larger version  Name:	Trace2.png Views:	1 Size:	203.5 KB ID:	1637667Click image for larger version  Name:	MaterialSlots.png Views:	1 Size:	83.4 KB ID:	1637668
      Last edited by DonBusso; 07-02-2019, 12:19 PM.

      Comment


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

        Comment


          #5
          Originally posted by Andrew Lindsay View Post
          Wow, that's exactly what I was hoping to achieve and it works perfectly! Thank you so much!
          Happy to help

          Comment

          Working...
          X