Download

Change/manipulate material at all meshes by specific tag

Hi all,

This blueprint toggles my light (pointlight) on and off and it changes the emissive color of the lampshade material .

Pointlight off -> Black emissive color - Pointlight On -> White emissive color.
Everything works fine but as you can see this blueprint works only with the one specific walllamp_A mesh.

How can I change the material of all lampmeshes with a specific tag in the scene? For example all pointlights with the tag “switchable”…

Hope somebody can help…You know I’m the graphic guy… :slight_smile:

Cheers Daniel

0447bd49956f468325c2da92927d8f89c77a3176.jpeg

Hey, click on your UseButton action and uncheck “consume input”

See if that works

:confused:

I do not really understand how that could work…

So you tried and didn’t work, or it did work and you don’t understand why?

There are other ways to make it work, lmk

First you need to set your source material in the construction graph - you also need to apply that dynamic material to your actors/components once you’ve created it. So following your create dynamic material node (and the one which makes the reference to it) you need to grab all of the actors you want to set that material to and apply the newly created dynamic version of that material to it. I take it your original material has those parameters?

(EDIT) - I’d normaly use a ‘get all actors of class’ node to get all of the lamps - I don’t know if there’s a ‘get all actors with tag’ node. - Use one of these and you can do a for each loop with each returned item in the array to set each item’s material to the dynamic one.

Dan

Hey Dan thanks for you help! The material itself is not the problem. It works fine!

With the GetAllActors and ComponentHasTag Function I can get all the lamps so I get a Array : VariableType - Lights but I just dont get it how to ‘connect’ this with the SetMaterial function. The target of the SetMaterial function is a Primitive Component Reference.

b2d7ef1915462163d67a477bf7e85964b12046c3.jpeg

Just hook up Array Element in the target.

By the way, did unchecking consume input not work? I’m really curious because I did your exact setup and unchecking that worked like a charm.

If - in the the image above - you drag off the ‘LightComponent’ (Which is the static mesh right?) and start typing set material, you’ll be able to texture that object with your emmissivedan dynamic texture - just attach that to the true node (and connect up the the exec pin of get actors of class obviously)

@vanlacke: No, the uncheck consume input didn’t work…

@Dannington:

I’m sorry but somehow I dont get it… :frowning:

The light component (your talking about the node at the bottom of the image?!) is a ‘Convert Light Reference to ActorComponentReference’. The only used mesh in this blueprint is the walllamp_A…

Don’t care about the component static mesh. It isn’t used…

Ok - I realise you’re within the object’s blueprint now. I’d test things by adding a tick event and adding a set vector parameter value to your emmisivedan texture and plug in a random vector in range node - then if it’s all set up your lights should be flashing randomly.

I dit it! It works! :slight_smile: It was my fault! I accidently ‘read’ the wrong actor class. I gathered the point lights instead of the static meshes. Stupid mistake!

Thanks for you help Dannington and vanlacke! I really appreciate it!

Cheers Daniel