How to set material with a map? [Solved]

Hi everyone,

I’m using UE 5.0.3. I tried to set the material of static mesh components with map and set material node.
I use a map because not all static mesh components use the same material. So, I created a map to store the corresponding material for each static mesh. What I want to do is, when the array index of the key and value is matched, set the material to that static mesh component.

However, It said I had an infinite loop.

Is there any way I can achieve what I want to do? Thanks!

The index doesn’t mean anything here, because a map can be accessed in any order, that’s the whole point :slight_smile:

If you were going to use a map, you would have something like mesh:material. Then you just run through the keys ( meshes ) and set the materials ( values ).

Thank you for your reply! Is this what you suggested I do? I set the map to be static mesh actor: Material instance. The map is great, with about 500 rows, but there is an infinite loop within the for each loop. :cry: Could you please provide extra help? Thanks!

You don’t need the double loop arrangement. Gimme 5…

1 Like

Many thanks!!!

It works! Before I saw your blueprint, I came up with using for loop and get array :sweat_smile: … But your way is much more convenient and neat!!!

1 Like

:sunglasses: