Change Materials of all meshes with Tag

Hello all! I have 3 different types of meshes in the scene (3 chairs) with multiple instances. All of them are sharing the same material.
I want to switch material on all of them at once on button press. How can I do this? I do know how to do it with individual meshes.


How to apply this logic to all chairs in the scene.
Thank You!

Hey @Kivril

First I’d like to point out that Input events shouldn’t be implemented on “outside” actors. All those should be linked to the Player, either on the player itself or its controller.

You can create a manager BP for clarity in charge of these mesh actors.
When the action is called (Input E), use GetAllActorsOfClassWithTag. Then inside the mesh actor you can have your own function or event with a parameter to tell it what material you want, and call it on a ForEachLoop from the manager taking the GetAllActorsOfClassWithTag array.

Your mesh actor BP

Your manager


Another option is to create a Dispatcher on the manager or control BP, and on the Begin Play of your mesh actors bind to that Dispatcher being called if they have the tag you want.

Your manager

image

image

Your mesh actor BP

Thank You! Now I have to dive in to this deeper. I thought it was simpler then this)

There can be many options, but here is one of them:

Create a function or (repeat its nodes in your logic):


this function searches for all actors that have a given tag, and all the static meshes of these actors that also have this tag, and changes the material of these static meshes to what you feed into the function

And call this function where your logic for changing material should be


image