MaterialInstanceDynamic(MID) and MaterialParamCollection(MPC) inside ForLoop

Could someone help me figure out why neither MIDs or MPCs pass parameters correctly to a DrawMaterial call when inside a ForLoop?

The array of floats being used to pass values to both the MID and MPC setups contain 3 values:
0.0, 0.5 and 1.0.

Expected result:
When rendered I expected the DrawMaterial call for both setups to display a black, grey and white square.

Actual result:
In the MID example only the last value in the array (1.0) is used for all three squares.

In the MPC example all three loop iterations are black. I don’t think the array value is being passed to the material for some reason.

Cheers.

Hey ash22 -

Material Parameter Collections is not the way you want to do this particular type of call. MPCs are meant to change a particular variable in multiple materials to the same value. The individual Materials that use the MPC cannot have different values.

Your first method was correct but you should move your MID creation into your loop that way each of your draw material calls can have a different value otherwise the same issue as with an MPC arises and you are assigning the same material each time and change the value each time so the last time it is called it sets all three because each is using the same material.

Here is a corrected BP, note I removed your Construction Script and the VID variable as unneeded:

Thank You

Eric Ketchum

Oh wow, Thanks Eric!

When I originally attempted to drag the CreateDynamicMaterial node from the palette the tooltip said
Function is hidden and inaccessible”.
I assumed it wasn’t compatible with the HUD for some reason. It didn’t occur to me to drag a wire directly from the
Set Scalar Param node to access it. Actually, I think I did at one point, but didn’t see the function because
[x]Context Sensitive was checked.

In one of Zak’s tutorials he does explain how nodes try to ‘help’ you find a contextual caller but I was so busy scratching my head over the ForLoop issue that it never occurred to me to uncheck [ ]Context Sensitive and look again.

Now I’ll remember it in future.

Cheers!