# How can I get all index from for loop in blueprint

**URL:** <https://forums.unrealengine.com/t/how-can-i-get-all-index-from-for-loop-in-blueprint/1476069>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [December 5, 2023, 12:12am UTC](https://forums.unrealengine.com/t/how-can-i-get-all-index-from-for-loop-in-blueprint/1476069 "2023-12-05T00:12:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 5, 2023, 12:27am UTC](https://forums.unrealengine.com/t/how-can-i-get-all-index-from-for-loop-in-blueprint/1476069/2 "2023-12-05T00:27:55Z")

</div>

> [@Lindsay\_Han](#):
>
> Is their anyone know where I did wrong?

The instances of a **single**  **I** nstanced **S** tatic **M** esh **C** omponent can only have 1 mesh and 1 material. What you’re doing will not work. Whenever you assign a material, you do not really assign it to **an** instance - you assign it to **all** instances of this one component.

You have some options:

- you could have 2 ISMc:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/d/95d3ad59afaf1be1490b2d08f5d396caa114f703.png)

The material can be pre-set on the component in the details panel.

- instead of ISMc, you could use as many regular Static Mesh Components as there are lights:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/0/2e0511b5ceb97390634f82594a09c41719785cc2.png)

- there is also a more involved technique - Custom Primitive Data

> **[UE Tip: Custom Primitive Data](https://unrealdirective.com/tips/custom-primitive-data)**
>
> Learn how you can use Custom Primitive Data to easily modify Scalar and Vector material parameters without needing Dynamic Material Instances.

> [@How to add a hit count (health points) to individual instances?](https://forums.unrealengine.com/t/how-to-add-a-hit-count-health-points-to-individual-instances/227176/2):
>
> The name of the game is Custom Primitive Data (check docs at the bottom). The material for a brick: each instance stores a float which is used to Lerp between 2 colours (to visualise hits remaining) this can (and probably should) get prettified Making a brick wall: create a bunch of instances and store their data in an int | int Map instead of an integer, you could have a struct and hold all kind of data here; perhaps this brick is worth some coins, or explodes when destroyed and …

[https://docs.unrealengine.com/5.3/en-US/storing-custom-data-in-unreal-engine-materials-per-primitive/](https://docs.unrealengine.com/5.3/en-US/storing-custom-data-in-unreal-engine-materials-per-primitive/)

This would actually allow you to achieve what you want. 1 ISM, 1 material, as many colours as you need.

---

_[View the full topic](https://forums.unrealengine.com/t/how-can-i-get-all-index-from-for-loop-in-blueprint/1476069)._
