Array material change

Hi,
I want to change the material of all meshes referenced in an array when clicking on a button set up in a widget.
The meshes are parts of blueprints which have an Interface implemented. I first selected these blueprint through a “Get All Actors With Interface” node. Strange fact, when putting a node “delete actor”, all blueprints are deleted at once when I click, but when I use a “set material” node, only one had its material changed.
Also I detailed the selection with a “Get Components by Class” node, selecting the Static Mesh Components of the last selected blueprints. Here again, only one object (the last created in the level) sees its material change.

But my problem is that in some case, not all the static mesh components of a blueprint have to be selected.
So I made an array manually by adding the specific mesh. But now, I can’t send the Array Element (through a ForEachLoop) in a Set Material node, since this node only accepts Primitive Component References…

Any idea how to do this please ?

Here are some screens :
Level Blueprint :

Widget Blueprint :

Thanks a lot !

Finally I’ve chosen to use the interface to call an event on each object I need to.
So I’m able to define separately which element of the object need to be modified.

A quick way to do this is to assign Actor tags (not Component tags) to the objects you want affected. You can do this from the Details panel > Actor > Tags.

Then, store those actors into an array, like so:

Then you need to Cast to Static Mesh Actor for each item in the array. This will allow you to access the Static Mesh Component and connect it to the Set Material node.

1 Like

Thanks, that’s definitely an easy way !

Hi, I am trying to do the same thing, Can someone explain how to get the cubesactorarray?

Sure !
In the level blueprint, select all your cubes and make references for them. Link them into a make array node, and promote this array as a variable. If all of your concerned actors are the same class, you can select all of them using “get all actors of class” (you can do this with tags too).

I love when people “help” without helping.
Could you be less precise please?, with the “sure!” I think that’s enough for me, I could even remove the “!”. Thanks.