# How does the material index work?

**URL:** <https://forums.unrealengine.com/t/how-does-the-material-index-work/714402>\
**Category:** FX\
**Tags:** unreal-engine, Blueprint\
**Created:** [November 24, 2022, 6:22am UTC](https://forums.unrealengine.com/t/how-does-the-material-index-work/714402 "2022-11-24T06:22:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [November 24, 2022, 6:22am UTC](https://forums.unrealengine.com/t/how-does-the-material-index-work/714402/1 "2022-11-24T06:22:43Z")

</div>

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)

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/b/2bbaade10bd5e8b8254d00c17e7228cd55732063.png)

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

 ![3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/0/47019a1591093e88db3e31edf4a5910e18825c00.png)

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.

* * *

---

<div class="post-metadata">

**Author:** ![lordlolek](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lordlolek/32/906205_2.png) [@lordlolek](https://forums.unrealengine.com/u/lordlolek)\
**Post date:** [November 24, 2022, 9:43am UTC](https://forums.unrealengine.com/t/how-does-the-material-index-work/714402/2 "2022-11-24T09:43:43Z")

</div>

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.

 ![Screenshot 2022-11-24 104007](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/d/a0d705d4b537b5083ab878ab6f8bcaa01ac8c9b6.png)

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [November 24, 2022, 10:04am UTC](https://forums.unrealengine.com/t/how-does-the-material-index-work/714402/3 "2022-11-24T10:04:06Z")

</div>

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!! 💖

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [November 25, 2022, 12:42pm UTC](https://forums.unrealengine.com/t/how-does-the-material-index-work/714402/4 "2022-11-25T12:42:34Z")

</div>

> [@Ivan3z](#):
>
> I tried something like that but it didn’t work.
> 
> ![3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/0/47019a1591093e88db3e31edf4a5910e18825c00.png)

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

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/5/b4532f45abf27f208e77fe7a213306dceb48ab35.png)

💪

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [November 25, 2022, 12:55pm UTC](https://forums.unrealengine.com/t/how-does-the-material-index-work/714402/5 "2022-11-25T12:55:54Z")

</div>

> [@Ivan3z](#):
>
> ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/b/2bbaade10bd5e8b8254d00c17e7228cd55732063.png)

and this works too

 ![2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/2/21215ca1ba7d9a4868fde9ebf6139fb00c35b1a2.png)

💪
