Hi, I came to a problem where I want to change a material colour in the run-time, but only on the selected object. If the same material is shared on the other object, the colour on it will be changed as-well.
Is there a way to separate these materials the easy way?
hard-way - I could create script to see if the material is shared and then create a new one and reassign it.
In Unity this is solved automatically by creating an Instance material - it appears only once in the whole scene in the run-time. Hence, the ties to a parent material is untied.
UE does have instance materials but they are called dynamic material instances. You can create them by using the Create Dynamic Material Instance node (or its C++ equivalent).
Alternatively, if you’re using a instanced static mesh component, you could make use of the per instance data in your material.
What Owlree said is summarized in the screenshot. Source material can be either material or material instance, and you assign the correspondent material slot that you want to change.
Thank you both!
I think that the creation of Dynamic Materials should be done in run-time, on Start?
Otherwise I will keep creating materials from materials?
p.s. to answer my own question, yes. I did this in Event Begin Play. No problem with that, and now it works correctly.
Glad it helped. You can make these changes at any time during run-time, not necessarily on Begin Play. It can also be triggered by external actors using ‘blueprint communication’ techniques, or via Level Blueprint. HTF do I? Blueprint to Blueprint Communication - YouTube