I have a character with two material instances assigned to it, one for the head and one for the body. The material derived from it got two textures files, one “healthy” and one “damaged”. The purpose is to have the material change from healthy to damaged as the character health gets lower or dies. I managed to create a blueprint that changes my materials to the damaged using a float number. However, it only randomly changes the head texture or the body texture to the damaged ones, not both. It should be both. How can I fix this?
That code will set the parameter only on the first material of the mesh. If your mesh uses more than one material, you need to loop through all them (there’s a function on the mesh to get the number of materials) and set the parameter on each one. You’ll also need to keep an array of dynamic material instances, not only a single one.
Some of my characters do have more than 2 materials. I’m kind of confused. I get what you are saying what I should do but I can’t seem to figure out how to correctly set it up. This is what I got so far. Is there a better way of doing this?
EDIT:
I fixed it, had to create a material index integer private variable, then connect it to the ForEachLoop node. See attachment and image for fix.