Changing material of a mesh.

I have created a blueprint that allows me to open a widget by grabbing a static mesh in VR and change the material of a static mesh.
Everything works great.
My only problem is that when I pick one of the materials for my static mesh it also changes it for all other (hand placed) copies of this BP.
Which is a shame because the widget opens and closes for each one individually.
I want to be able to place multiple copies of this BP in my level and change the color of each of them individually.

the BP is made out of 2 components, a Widget and a Static mesh

inside the Widget graph I activate a custom event when I click a button.
I named the buttons R G and B but I changed the colors on the widget to match the material.
So Button_R corresponds with the Blue button with the 1 on it. etc

after that in the pillow and widget BP I set material when the custom event (button is pressed) fires.

I suspect the problem is in the Get All Actors of Class node since it gets all actors within the level and I should find a way to get only the actors within a single instance.
Sorry if this question is a bit simple, I’m still a blueprint noob.

From my understanding you’ll need to change the actors withing a single instance. But i’m also a noob at this, my problem is the opposite of yours. I’m currently trying to change multiple actors off one BP with absolutely no luck.

ok lets tackle booth problems at once :slight_smile:

In your third image you have connected the GetAllActorsOfClass output with the Events of setting the material. I would suggest that your widget contains a reference to the corresponding object. Whenever you click the button you just call isBlue etc. on the corresponding Object and not on all Actors of that class. You can enable expose on spawn on the widgets reference variable so you can set it when creating the widget.

And whilst the other one could just copy yours he would still have the problem of making a different class for every objecttype. Thus I would suggest saving all walls, floors into arrays then iterating over them with a For Loop and setting the color for each singular element.

However once you get used to unreal you should probably take a look here Event Dispatchers

Thanks for your reply Sven, but I still cannot get it to work.
I have created a variable of the ColorPickerPillow_BP and tried to put that into the the target of isRed? but the variable is empty and I have no way to put anything in it.
When I playtest I get warnings that the variable returns Null.
I have Expose on spawn on but I cant find anywhere to put in a reference to the Blueprint either.

The only way I could find to add something into the variable was by changing it to a ‘object’ instead of an actor but in that case the isRed? doesnt accept it as a target.

So how and where do you create the Widget with the colored buttons?

I have the Widget Blueprint which is where I created the widget with its 3 buttons in the Designer part.
Inside the Graph part of this widget I have the Onclicked → IsRed? action for each of the buttons.

the Blueprint that I place in the world is a second blueprint with 2 components.
A Static mesh with the material I want to change and the Widget.
Inside this blueprint’s event graph the Custom event (isRed?) is linked to the SetMaterial.

I don’t think I can do it all in 1 BP because I can’t access the individual buttons onclicked event, which is why I have to create the custom events.