In this post we’re going to see how we can communicate with the Material Editor and change specific parameters of our Materials during runtime.

Creating a dummy Material

Create a material which consists of two parameters:

  • A Vector Parameter, connected to the base color input
  • A Scalar Parameter, connected to the metallic value

Here is a screenshot of my material so far:

material

Note that I’ve named both parameters with a desired name. In order to name a parameter, click on it and then modify the Parameter Name value.

Accessing material parameters

Create a C++ class which inherits the Actor class and add the following component inside the header file:

Then, inside the source file, type in the following code:

Once you’re done with that, compile your code and create a Blueprint based on your C++ class. Then, choose a static mesh of your desire and assign to the first Material slot the material you have created in the first step of this post:

colorActor

When you’re done with that, place some actors on your level and play the game.

Check out some results of mine:

dynamic_materials_output_shortened

 

Share postShare on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0