Overlap swap material - Multiple Object

Hi,

I got an issue trying to get object to swap temporary material when overlapping by the weapon from the player.
First, I did per object collision (ex: Brick begin overlap → store original material → apply highlight material / Brick end overlap → apply stored material).

But I had to do that for every mesh in my level. Was ok when only 2-4 objects needed this, but now I got a level with about 70 objects. So I decided to create a general rule ;

ex : If weapon overlap object of this collision type → add object to array → loop through array to store material in a different array based on index → apply highlight material. /
When weapon end overlap - > get object from array - > loop through array and used the material stored at same index and apply to object.

So if I overlap 2 objects ;

  • Object A stored at array 0, his material is stored at array 0, Object A get applied Highlight material.
  • Object B stored at array 1, his material is stored at array 1, Object B get applied Highlight material.
  • On end overlap, each object get his material reapply.

This works at the condition that I go from last in, first out.
If not, the array fill the gap, so Object B get material stored in 0.

Any idea how to force an array to not fill the gap?

On side note; what is Other Body Index and how is it calculated?

Thanks.