Can I bind a Dynamic Material Instance parameter to a variable for automatic updates?

Is it possible to bind a variable in a class to a dynamic material instance parameter so that changing the variable automatically changes the material instance?

I have a pawn with a dynamic material instance that has color parameter, and I want that color to be reflected by a LinearColor variable stored in the pawn, similarly to how you can bind a function to a LinearColor attribute for a Text component in a Widget and then whenever you change the variable the text also changes its color automatically.

Or is the only way to do this to make an event fire off whenever I change the color variable and then manually set the dynamic instance parameter value whenever that event fires?

You’ll have to create an event, or alternatively, use a material animation curve that’s named the same as the material parameter.

Not directly… but if you want it badly, you can create a variable that has Replication setting set to RepNotify (it is a networking tool). Then, inside the OnRep_variableName function you can call the event to change specified material parameter.

Whenever you use “set” operation on this variable, the OnRep function will fire.
Note: increment/decrement will not fire this event, but you can set the value of variableName with the value of variableName :wink:

This will only work for BP variables and has terrible and unnecessary overhead for this purpose.

True about C++, it would require additional function call, which is pointless, as OP wanted just to change the variable. Overhead? I’m 99% sure it won’t be the performance killer, it would had to be very specific project…

True but it is still going through network-intended channels and the whole replication mechanism just to avoid a single function call.

Welp, event it is then!

This is a multiplayer game, so since I can’t bind the parameter to a variable I’m going to have to use a NetMulticast function anyway.