Changing the Materials using UMG Buttons

The concept I’ve given you above works in 4.7 the same as in 4.6. I went into a blank 4.6 project and re-created it using the steps I mentioned, still works.

The technique works in 4.6 the same as in 4.7

Sorry that I didnt explain you fully in detail. It works in editor 4.6 but the problem is that I have 3 level buttons (Level1, Level2 and Level3) and 3 cones which will display when the game begins (i.e when EventBeginPlay). In all the 3 levels, I am doing the same thing. If I am in Level1, I have 3 cones. If I click on any cone, the M1 and M2 button will display to change the material for the cones. After changing the materials in Level1, when I click the button Level2, it should go to another level. But instead it crashes and closes the editor.

But this problem is not there in editor 4.7

I have attached an output window here to understand:

This blueprint solved the issue. Anyways thanks!

Thank you so much for this Justin. I’ve been trying to figure this out for the longest . It still took me some to learn about how you even got some of those things on the blue print like the widget variable, but eventually I figured it out and set it up the way you demonstrated.

Hello Justin,
Thank you so much for your ! I am having trouble implementing your BP to my project where I want a similar interaction. Shortly, when I fire ‘E’ key, UMG menu pops up and there are several color buttons for material changing. As you did above, I set my Static Mesh Actor to a public variable called My Wall, and ‘GET’ it in UMG. In UMG, My Wall variable comes with an empty Target node slot, and converts it to Static Mesh Component before plugging into Set Material Target, therefore gives an error while compiling, telling me Target must have a connection. What am I doing wrong? Any ideas?

You can’t SetMaterial on nothing, that’s why it’s asking for a Target. Provide it your Static Mesh Actor as the target and it will be fine.

Thanks Justin! I figured out I was getting the wrong variable (testing different logics made it confusing heheh) that is why it didn’t recognize it. It works perfect now, thanks to you :slight_smile:

Hi there, I’m with a related problem, but I’m not using UMG, I’m trying to do this: I created an actor that when I click on it, it changes it’s color, but what I want to do and I’m having problem is, when this happens, I want to set a material for another class that spawns at my will. Please help, I’m new to unreal

who can help me about that? i can not connect them :((((

who can help me about that? i can not connect them… :(((

Hi Justin,

I’m actually trying to use the same system you described.
However I’m stuck : I use a blueprint made out of a static mesh actor (cube). Here I made my blueprint with a Widget variable, create the widget, set the Static Mesh Component as an variable (named cucube), then add the widget to viewport.
However I’m working on the 4.10.2 version, and I can’t find why your Set Cone node has a target slot (mine doesn’t). Is that due to the older version used ?

Also despite all your explanations, I didn’t understand how you linked your “Cone” variable on the widget with the one set on the Static Mesh Component Widget ? When I try to link “cucube” in the target slot of the Set Material node, it asks for another Target for this variable.

In my complete setup, I’m using a HUD. Is the widget creation useful in my case ?

Thanks a lot !

Hi Teapot.

The cone variable is in the spawned widget not in the cube blueprint. Drag a pin out from the create widget pin and use the set cube function. the target will be your spawned blueprint and the cone (or in your case cube) will be self (since the blueprint is made from the cube)

■■■■’, I think I’ve missed something.

By now, tell me if I’m right : in the cube blueprint, I create the widget and define the widget variable to work with. Here I have to set the static mesh as an reference, since I can’t make a reference in another blueprint for this cube (only the level blueprint but I don’t use here).
But in the spawned widget, I have to use the variable ( reference)…

Where am I wrong ? I’m lost x)
Thanks !

Hi, it’s finally OK.
The last hours of the day weren’t the best to try this :slight_smile:
This morning I succeeded fast in making it work. Thanks again !

please video tutorial