Download

Help with Dynamic Material Instance

Hey guys,

I’m trying to turn a light off and on. I need the lightbulb and lampshade material to change their emissive amount when I do so.

I’m multiplying by a scalar parameter in the materials. Here’s the bulb:

3.jpg

I’ve placed the DMIs in the construction script like this:

Untitled-1.jpg

Finally, you can see the BP firing off in the event graph. The lights are toggling, but the emissive amount isn’t being affected. So, I’ve missed something somewhere.

1.jpg

Can you spot the problem?

In your construction script, you are first setting “AIUE V01 004 BedroomChandelier 001”'s material at ID 0 to the lampshade material, but then you are replacing it with the bulb material in the same material ID.
If that’s not the problem, try putting some print string nodes after your timeline and print out the values of Lightbulb MAT and Lampshade MAT, and confirm they are what they should be when they should be

Thanks for the reply!

My print strings are spitting out the correct values.

I have two separate materials attached to my mesh. Both need to change. The target is the same mesh, but I’ve changed the source material in each (and those are two separate DMIs). That made sense to me, but maybe it doesn’t! Any help there would be appreciated.

That said, setting just one or the other doesn’t produce any change in the emissive amount, so I am still stumped.

Does your mesh have two seperate material IDs though (elements)? If so you will need to change the element index on those create dynamic material nodes, so that they both are applied to different IDs on the mesh. So, one would have 0, and the other would have 1.

It seems like that isn’t the issue though anyway, like you said. Can you post a screenshot of what is in the timeline node?

That was it! They were elements 1 and 2, so have both DMIs set to 0 was giving no result(obviously!).

Thanks for the trouble! Silly mistake on my part (I thought I was setting the farget material by changing ‘source material’).