How to get Index of a Colliding Mesh Instance

Hi,

I’m looking to get the index of a colliding mesh instance.

I’ve got an asteroid field and a harvester.
The asteroid field contains an Instanced Static Mesh Component where I create numerous asteroids with different transforms.
The harvester has a collision sphere that only detects overlaps with the asteroid.

So when an overlap occurs, how can I get the asteroid index to make sure it’s colliding with the correct asteroid, the correct asteroid being the actual asteroid it’s trying to acquire, not one that it may have accidentally came into contact on the way there.

If there’s no proper way with BP, the only alternative option I can think of is, when there’s an overlap, check co-ordinates and distances to see if I’m close enough to it.

I am currently also looking for this. Did you manage to find a better solution?

Hit result returns an index. That will be the index of the instanced mesh that the hit collided with.

If you’re not receiving an Other Body Index when overlapping with an UInstancedStaticMeshComponent, you need to make sure that the component’s bMultiBodyOverlap is set to true. By default, UPrimitiveComponent (UInstancedStaticMeshComponent’s parent class) sets this to false, in which case the Other Body Index will always be set to -1.

For Blueprints, Multi Body Overlap is found under the advanced portion of the Collision section for the InstancedStaticMeshComponent.

Source of answer:
ConvertQueryOverlap() in CollisionConversions.cpp is where the overlap information is built. In this function, OutOverlap.ItemIndex will be set to either -1 (when bMultiBodyOverlap is false), or the instance body index when bMultiBodyOverlap is true. The same is true for destructible components.

1 Like

you are life saver

If anyone is having problems activating Multi Body Overlap on foliage it´s because you need to create a new foliage class and then on that class under collision you will find it.

No, it doesn’t.

It does if you set “Multi Body Overlap” to true like Gnometech stated earlier.