With this line you can create a dynamic material instance Creating the Dynamic Materialįirst, we need to create a dynamic material instance of the material attached to the object.
#Enroute 4 material set up how to#
Now that that is out of the way let’s look at how to change the properties of a material from an object at runtime. By default, some basic properties are available, such as changing the colour, but you’ll need to expose the parameters in case you need more complex ones. There are two types of Instanced Materials:įor our case we will be using dynamic material instance, as this type will allow us to edit properties at runtime.įYI: Not all material parameters can be changed at runtime.
An instanced material allows us to change the material without needing to do expensive recompilations. Thus, we make use of something called a Material Instance. A typical material cannot be edited or changed without recompiling. Well, let’s get onto the interesting now! So, how do I change material colour or other properties at runtime?įirst of all we need to understand, that you cannot edit the material attached to an mesh directly at Runtime. The whole Unreal Engine 4 project being used is available on my Gitlab profile or following through the link here: Īll the code written by myself is licensed under the MIT License, the unreal engine and the base template are copyrighted by Epic Games. The reason for creating these blog posts is to release more knowledge about using C++ in UE4, as there’s tons for blueprints, but not so much for C++.
With these mini tutorials, I’ll be explaining small implementations of features that are helping me learn the engine. Recently, I have started to learn about Unreal Engine 4 and C++ programming to up my skills.