# HISM index problem

**URL:** <https://forums.unrealengine.com/t/hism-index-problem/499183>\
**Category:** Rendering\
**Tags:** hism, unreal-engine, UE4-27, question\
**Created:** [February 17, 2022, 3:33pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183 "2022-02-17T15:33:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KetherGame](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kethergame/32/912204_2.png) [@KetherGame](https://forums.unrealengine.com/u/KetherGame)\
**Post date:** [February 17, 2022, 3:33pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/1 "2022-02-17T15:33:13Z")

</div>

What exactly does the return value of “Add Instance” function mean?  
I think it’s index of instance, and it auto-increment, but some time, like after removing instance many times, the return value may go low like 0 or 23, which the instance I already removed, why? Did I misunderstand the meaning of the return value?

---

<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:** [February 17, 2022, 4:25pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/2 "2022-02-17T16:25:20Z")

</div>

> I think it’s index of instance, and it auto-increment, but some time, like after removing instance many times, the return value may go low like 0 or 23, which the instance I already removed, why?

HISM indexes must live in a continuous ordered unique list. If you make a hundred, they’ll be ordered from 0-99. If you remove the 25th, another instance with a higher index will take its place and lose its own index! From an older thread of mine:

Note what happens to indexes when a random instance is removed, some other instances have their indexes reassigned. This used to be a massive issue up until 4.26 - were you to add LODs to the mix, the indexes would jumble up really quickly…

* * *

Another example from yet another thread regarding this:

Initially the spheres are ordered, their shade indicates their indexes. HISM components support _per instance culling_ - off screen instances get removed from the index list (great for performance since we can render only some of them!). But if they’re not on the list, the HISM component needs to reorder indexes to fill in the gaps.

When they disappear on the right hand side, these are the high indexes - nothing needs rejiggling. 0-100 became 0-70 let’s say. It’s still neat.

Low indexes disappear when culling kicks on the left hand side. Now we have an index list of 30-100. The HISM will have none of that and will fill the initial indexes with something from the back. As you can see, this is quite chaotic.

The above was done using _per instance custom data_.

---

<div class="post-metadata">

**Author:** ![KetherGame](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kethergame/32/912204_2.png) [@KetherGame](https://forums.unrealengine.com/u/KetherGame)\
**Post date:** [February 18, 2022, 11:07am UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/3 "2022-02-18T11:07:27Z")

</div>

I want make a crowd with HISM, and make every one of them have HP, can be damaged and destroy.  
I made a map/dict with int key(instance index) and float value(HP), but as you said, the index of HISM is not “stable”, the index of HISM won’t point to the same instance, btw, I got the index from hit result-\>hit item . how can I fix it, or HISM can still works for me ?

---

<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:** [February 18, 2022, 2:14pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/4 "2022-02-18T14:14:34Z")

</div>

The HISM culling shenanigans improved dramatically.

Removing indexes still works the same, though. You can use a Dictionary for storing values but you’ll be unable to remove instances without indexes shifting about - making the data that resides in the Dictionary stale, useless.

* * *

One solution is to _not_ remove instances, hide or move them out the way instead:

Here’s a small thing that hopefully demonstrates it better:

> [@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 …

---

<div class="post-metadata">

**Author:** ![KetherGame](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kethergame/32/912204_2.png) [@KetherGame](https://forums.unrealengine.com/u/KetherGame)\
**Post date:** [February 18, 2022, 2:48pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/5 "2022-02-18T14:48:09Z")

</div>

Wow, Thanks, But culling will change instance position too, like pic 2 in your last answer, so, if I move a instance too 0,0,10000000, it will go back because cull, I didn’t try it yet, that’s just my theory, should I turn off culling?

---

<div class="post-metadata">

**Author:** ![KetherGame](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kethergame/32/912204_2.png) [@KetherGame](https://forums.unrealengine.com/u/KetherGame)\
**Post date:** [February 19, 2022, 1:45pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/6 "2022-02-19T13:45:23Z")

</div>

I tried, It’s works well, You saved my day, Thank you!

---

<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:** [February 19, 2022, 4:48pm UTC](https://forums.unrealengine.com/t/hism-index-problem/499183/7 "2022-02-19T16:48:16Z")

</div>

Yup, there was a lot of work done on HISM between 4.25 - 4.27. Indexing is manageable.
