How does the material index work?

I’m overriding index zero with my dynamic materials. That seems to be the only way to make it work. Is this correct?

When I instantiate a dynamic material it seems that the index doesn’t matter much as long as it won’t be the zero index.

In fact I can’t get the index to increase when I add a new material.
(Or maybe it’s not the correct way to get a valid automatic index)

And how to know what material is currently in index zero?.
I tried something like that but it didn’t work.

So, it looks like an Array, but it doesn’t work like an Array…
I’m sure I’m doing something wrong…

What is the right way to do it?
Thank you very much!!


Note: I can’t put the QUESTION tag… The web seems to be broken since yesterday.


I’m not sure what you are trying to achieve, but the material index is the index of the material slots array in mesh. So, setting material with Index 0 means you will override material assigned to first material slot, and so on.

1 Like

Hi

I am changing the material of my pawn depending on the effect that I want to obtain at each moment. So I want to know if the current material is the default material (no effects) to restore it when necessary.

Ok, now I understand why only zero index works for me. It’s because my pawn only has one material.

I thought that when you created a dynamic material it was inserted into the tail. Same as an Array or List… I see now that it doesn’t work like that.

Thank you very much for answer. This has been very helpful to me in understanding how it works!! :sparkling_heart:

it works!!
But you have to put a name to the material when you create it.

:muscle:

and this works too

:muscle: