Set Material from String

Hi!
I’m trying to figure out how to use the “Set Material” function starting from a material name from a String variable.

Any advice?

Thanks in advance for your help!

Have look to this video.

You are always welcome to post your questions, but, please spend a few hours and watch the tutorial series that provided by UE4 guys. I am sure, they already answered 99.9% of all possible questions in the tutorials :))

Thanks for your reply.

Sadly, the video isn’t providing a solution: i cannot use dynamic material, since i’m also changing the blending and that particular property cannot be dynamically changed without recompile shaders at runtime, which is something i’m not going to do.

The only solution is to create a copy of an existing material (eg: “concrete” and “concrete_transparent”), change the blending function and setting an alpha value to the cloned material, then in a blueprint use the “Get Material” + “Get Display Name” to get the String representation of the material name (eg: “concrete”), append to the string the “_transparent” and use the Set Material to change from “concrete” to “concrete_transparent”.

The only problem, is that i don’t see how i could “find” a material by string, to be passed to the “Set Material” function. I mean, “Set Material” wants a “Material” variable, while i only have the Material Name as a String representation.

Could you tell me what parameter of the material exactly do you want to change?

Sure!
Blend mode: from Opaque to Translucent

15507-screen+shot+2014-09-16+at+12.04.10+am.png

Set Opacity to 0.1

15508-screen+shot+2014-09-16+at+12.04.25+am.png

I think i can change the Opacity with a dynamic material, but AFAIK there is no way to change the Blend Mode.

Here is the problem. In order to change a parameter of a material, you need to convert it to parameter. If not, it will not show up, or you can not change the value through “Set_Scalar_Parameter_Value”.

Right click on the constant node and click on “Convert to parameter”.

15500-capture1.png

Why not just have the material’s blend mode always on Translucent?
100% opacity in a Translucent material is the same as an Opaque blend mode so far as I know.

Yes, you are right, but i still need to figure out how to change the blend mode… Which is the main reason why i’m cloning my materials instead of dynamically change them at runtime.