I’m having an issue with HISM instance indexing
I spawn multiple coin instances in BeginPlay using predefined transforms. However, when collecting a coin, the system always removes the instance at index 0, regardless of which coin was actually hit
It appears that I’m not correctly retrieving the Hit Item (instance index) from the trace or overlap result. As a result, I’m unable to pass the correct index into an integer variable to remove the intended instance
Other Body Index or Sweep result hit item always is -1 index
First off your Remove Index call is telling it to remove index 0.
You should be tracing and taking the hit result and getting the actual index from the HISM instance. Then remove that specific instance.
Also note that the HISM instance array will shift indexes as items are removed. Meaning if you have an array of 100 elements (0-99) and you remove index 97 the array will shift down resulting in 0-98. Index 98 is shifted to 97 slot and 99 shifted to 98 slot.
If you need to remove multiple in a loop you need to sort your remove indexes in desc order, thus removing highest index first… because of the shift.
Here’s how to sort your indexes