Blueprint To Change Material Multiple Times

Hey guys im pretty new to unreal engine and scripting in general.

I have been trying to figure out a solution to create a blueprint which will allow me to press an input button and as a result will change the material of, for example a wall. If i was to press the same input button again it will change the material again and if i press it again it will continue to change and so on until it reaches the first material.

For example if i had a brick, wood and glass materials that i wanted to change on a wall and my starting material is brick and my input button was 1 to trigger a material change, the wall will go from brick to wood, then if i press the input button 1 again it will go from wood to glass then finally if i pressed it again from glass to brick.

i have provided a script that i have found from youtube which i made in unreal but it only allows me to change material once and i cant loop materials.

Can anybody help me, visual images will be much appreciated!! :smiley:
Thanks in advance!

You could try something like this, its basically getting a random int when you press your button and setting a material depending on what that value is, this however will be completely random and may not be what you want but i hope it helps.

There’s actually a much simpler way to do this, IMHO, which allows you to easily add extra variations to your material sequence:

Awesome i didn’t know that existed, thanks for sharing.

Thank you very much for that. it really helped !