changing materials in runtime

I made a two materials(instances) and write a blueprint script. But it doesn’t change like i made. It changed like the default grey color material.
267902-

1 Like

Hi !

In order to change material at runtime, you have to create something called Dynamic Material Instance (DMI). Right click on your BP background, and search “Create Dynamic” it should pop up. Once you have done this, you set the material ith the node you have used, in the begin play of your actor, to that DMI.

And from this DMI, you have nodes called Set Scalar/Vector parameter values, wich will allow you to change the material parameters at runtime :slight_smile:

Have a look at this if some things are unclear : Change Material at Runtime - UE4AnswerHub Answer posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4

1 Like

but I don’t want to change the parameter values, i just want to change to the other material I made with the jpeg file. Can you tell me how to do this…?

1 Like

I’ve been running into the same issue - the material swap occurs at runtime, but for some reason it shows the default material, as if the one swapped to hasn’t been compiled yet. I’ve found that if I set the preview mesh in the editor to the mesh that I’m trying the swap on it will work.

I haven’t tried it in a packaged game yet, but I suspect this is an issue that only occurs with uncooked data.

1 Like