Change material static mesh

Hello.

I have seen some topics already concerning this matter, but none of those seem to work for me.

I have a blueprint with an aircraft (BP_Aircraft), consisting of several static meshes. I also have a widget with some buttons. By the click of a certain button (TestButton) on this widget, I want to change the material of one of those static meshes (Cabin Main) in the blueprint BP_Aircraft to a fixed material that I have (Glass) and change it back to its ‘original’ material (Metal) when clicking the same button. What I have now is this for only changing it to Glass:

With some topic discussions, this should work (since I have set the material and the actor class). Some other topics state that I need to create a dynamic material instance and then attach a material variable to that, but for me that would be strange I think since I’ve fixed the material to Glass. In any case: nothing works for me and I don’t get errors, so what I have is not wrong but it does miss something. I just have no idea what I’m missing.

I hope anyone can help.

Create an event in BP_AirCraft … Update Fuselage

Update FuselageSet Material (static mesh component)

In the Widget get a reference to the BP_Aircraft instance and call the Update Fuselage event.


Semantics wise you should not be using Get all Actors of Class for this. You should have a direct reference to the specific instance before clicking the button. How is dependent on what class is implementing the UI and your overall setup.

(post deleted by author)

Hello, I tried this but I get a lot of errors:

I tried this, but I get some errors.

In the aircraft blueprint I have:

Then I have this in the widget:

Where Aircraft is:

image

When I run it, nothing happens and I get: