Download

Pass Material Instance to Function

I want to create a function that takes a material instance as a parameter and then does some things to it. How do I set the function to accept a material instance as a parameter?

You mean a material instance that takes a material parameter collection that is then altered by a function?

Um, I’m not sure, you’ve confused me?

In the construction script I create some material instances from some materials.

Then in the event graph I do some things to those material instances in order to animate them. I’m doing the same set of steps to each material instance. So I thought, maybe I could create a function of these steps (nodes) and then just pass in the material instance to the function, so I don’t have to have all the nodes duplicated for each material instance in the event graph.

OK, so I worked out how to create an input variable to the function, which I’ve set to be a Material Instance. In the event graph I have the material instance connecting to a Get Vector Parameter Value node. However it won’t let me do that in the function with the material instance input. See below.

Event Graph - Working
1.png

Function - Not Working
dc05305999ecab0af606aaf4bacf3ef93fcbc04b.png