How to make dynamic material for mesh instance in Blueprint?

I want to make a blueprint that can dynamically switch the static mesh using a Set Static Mesh and New Mesh is promoted to a variable; and then I want to be able to dynamically change the material of that mesh with a dynamic material instance. But I don’t know how to make the Target for the Material Instance reference the instanced mesh. Like, I want the dynamic material to know what mesh is being instanced and apply the material to that mesh; that way I can use one blueprint and create a lot of different meshes but all have the same logic regarding the material, thus avoiding duplicating the blueprint 30 times so each static mesh can have this material that behaves how I want.

The dynamic material instance will be ( typically ) made per blueprint, so you will have a different copy of the DMI on each mesh.

If you want to be able to tweak one material, and have all the meshes change at once, then take a look at parameter collections:

1 Like

Ok, so that’s very cool, but I would still need to create many material instances. I want a way to make everything happen in one blueprint. Ex. I have a clock, chair, and table, they all have the same material, but with differently adjusted parameters. Can I have the static mesh and the material parameters all being exposed variables in one blueprint?

They would need to be different material instances, otherwise they will have the same parameters.

Normally, you would have a chair BP, with it’s material, adjustable from the BP. And then a table BP etc…

You could make one central BP and control all the meshes and materials from there, it’s possible.

Well, in my case, I have at least 30 differentl static meshes so it seems much faster to have them in one bp and be able to change them within the editor. But the question is how? I know how to make multiple meshes in one BP, like this:


And I know how to have a dynamic material like this:

But how to combine them into one happy family? I don’t know how to make the Target on the Create Dynamic Material Instance to “see” the mesh I have instanced from the Set Static Mesh.

Just make one BP, which sets the mesh and the MI.

Put it in the level, and you can set the mesh to be chair ( or whatever ), via the exposed variable.

You can control the specifics on the MI on the BP, but also the whole group via the parameter collection.