Dynamically change diffuse map of a material

I would like to be able to change the diffuse map of a material while the game is running depending on certain conditions. I know you can change the material of an object in the flow graph, but I want to be able to have just one material and change the diffuse map as needed. Is there any way I can do this in the flow graph editor? Or would I have to use C++? And if I would need C++, what would you recommend as the best way of achieving this?

In the time since I posted this, I found a solution for doing it in C++ that involved loading a new texture and setting the pointer of the material’s diffuse map to point to the new texture. (Link to thread with solution). Of course, if there is a more elegant way of going about it, I’m open to suggestions.

Hello @CameronT,

Currently, there is no support to change out only the diffuse map of a specific material in game.

But you are correct that you can swap out the entire material. You can duplicate the material and change the diffuse on the new material, then using flowgraph, make the material swap.

I can understand how this might not be desireable if you need to manage a lot of duplicate materials.

As for the C++ option, I’ll investigate if this can be done and get back to you as soon as I have an answer.