How to change colors into the game?

Hey guys, I have some problem to do a one thing into UE4, I want to change the color materials into de game, well, when I play, I want to change a objects colors, materials, explain: A door, change the color with a command or icon, I’ll must show you guys what I saying, thanks:

Hi there,
you need to create something called a dynamic Material instance. this is a materiel that has a parameter (such as color) that you can change while the game is running. you then have to change that parameter in a script. in your example video that was done by scripting some kind of interface with a selection of linear color values that are passed to a parameter in the dynamic Material instance.

Epic has a good video tutorial on the subject here:

i expect that if your not currently able to use Blueprint scripting you need to know most of the fundamentals to get a result as slick as the one in your video. (unless your good at C++) if your interested in Blueprint, Epic also has lots of great tutorials on that:
i hope that helps :)

Thanks a lot guy, I’ll try do it, i hope i can do it lol.
Ty u guy! :smiley:

You can achieve this with materials and material instances. The first thing you have to do is to add a parameter into you material, for instance a vector parameter as show in the image below. You will give you parameter a name which we can later use to change the value of it.

Once you have created you parameter you should create an instance of your material, just right click on your material and choose create material instance. Attach your material to your mesh for example (you can also just add it as an editable property of you like).


The next step is to create a copy of your instance in your construction script so that we modify the copy instead of the original one, if you do not create a copy of the material the changes will be applied to all places where you use you instance. In the example we use an editable property of MaterialInstance. Once you have created promote it to a variable and set it to be the material for your mesh. Remember that this should be done in the construction script!

Construction script of a simple BP. The BP has just a cube mesh called mesh added as a component.

The following example will change the color to a random color every second to demonstrate the changes.

The event graph with just the Begin Player event and a loop that will launch every second.


Final result of the cube

Okay man, I’ll try, thanks a lot! :smiley: Sup

Guys, I can change the color and materials, it’s okay, but I want to do it with a command (mouse click) with icons to show the possibility of change those colors.

Just do the same I do in the event loop from a mouse event if you like, to change the texture itself the material I posted features a parameter for that too.

Hum, I can understand, I’ll try do it bro, ty u!

Thanks guys! I do!
Ty for ererything guys! :smiley: