I fixed it! What you have to do is create a private integer variable called “MaterialIndex”. So since most of my characters have 2 materials (head/body), a few also have 3 or 4 materials as well. So if you want the blueprint construction script to check how many materials the mesh have first before swapping out the textures in the materials. (The global material got a lerp node with a parameter node that changes one texture to the other for the base color/roughness). Connect the “MaterialIndex” variable to a Make Array node, since most of the characters have 2 materials but some have 3 or 4, add 3 more pins to the Make Array node, if the mesh does not have a 3rd or 4th material, it will automatically return nothing (NULL) and ignore the 3rd or 4th pin. Connect the Make Array node to a ForEachLoop then connect the Script to the ForEachLoop to the Create Dynamic Material Instance. Compile and try sliding the DamageTotal (public variable float) from 0.0 to 1.0 and you will see all the textures being swapped out to the “dead/damaged” one.
1 Like