I created a material that changes color. How do I prevent color change on the decals created by it?

Essentially, I’d like to spawn some decals in one color, then change colors and spawn some more. I’m creating the colors via random RGB values (for now). But, since all the decals point to the same material, all of the decals are changing whenever the material changes color.

Is there some way to prevent this, so that only new decals spawned will maintain the original color? There will potentially be many, many different colors, so creating a new material for each color I need isn’t really practical. I was thinking about making an array of instances of the material (if that is possible), then whenever the color is going to change, simply switch the decal spawner to point to the new material instance. I’m not sure if this is possible though.

Thoughts?

I guess it might be possible by creating a dynamic material instance for every new color, but I never tried this so I am not sure if it works. If not you might have to work with static material instances (a kind of new Material for every color).

This is the proper way. You create a dynamic material instance per set of decals. To be clear, this is not creating a new material or material instance in the content browser, you should be creating these at spawn time in your decal using the create dynamic material instance node.

Thanks for the response. I understand now that I need to create a dynamic material instance for each set of decals, but I guess I don’t know quite how to implement it. I’ve tried a few things, and this is the current setup (which properly changes colors, but doesn’t keep old colors which is my goal).

Here’s the blueprint collection I’m using to change color. Note the first three are static colors, and the fourth changes to a new random color each time it is selected.

Then I also have this blueprint to do the linetracing to find out where to put the decal, and spawn it:

Finally, note that I have two objects in play here:

ColorChanger_Mat is a Material Parameter Collection, and simply stores one vector parameter.

ColorChange_Mat is simply a Deferred Decal material with a base color reference to the ColorChanger_Mat.

So then, any idea what I am doing wrong here? Why am I not getting different instances of the color changing material?