Change parameters of mesh with multiple materials
Greetings, i'm currently working on a Top/Down Adventure game and i've stumbled upon a problem I'm not exactly sure how to fix. So basically I have a blueprint that makes a mesh turn transparent if it gets into collision with the player camera. This system works fine but the problem is that it only works if the mesh has one material. I kinda understand where the problem is I just don't really know how to implement a solution. I believe that the solution lies with how the dynamic material is created in Event BeginPlay. When I GetMaterial from the Static Mesh the element Index is set to 0 so I imagine thats why it only affects the first material and not the rest. Im not sure how I would go about making it create a dynamic material for each material within the static mesh. Arrays are probably the solution? Any ideas?
asked Mar 30 '19 at 09:06 PM in Using UE4
if you have multiple materials then you should just need a loop which repeats the process for each material. on begin play you will get the number of materials then run a for loop for each material. the get num materials node should output a number greater than zero and the material indexes are zero based so you will likely need to subtract one from the num materials. after that is basically the same procedure you were doing. the exception comes at the end where your storing the materials in a variable, here you will want to add them to an array via the add node. the other change comes in your update vis function here you will again need to loop to go through each material instance. so you get your array and use a for each loop which will run the script following it for every material stored in the array.
Follow this question
Once you sign in you will be able to subscribe for any updates here