you were right about not needing to call overlap on every loop iteration. I didnt realize that the lower index values would still be valid if you start from the top. I ended up finding a way to get it done in c++. The only thing I’m doing in blueprints is setting the value of ‘arrayOfFoliageTypes’, because I cant seem to compile when including the procedural foliage headers.
Here’s my code if you’re interested.
for (UInstancedStaticMeshComponent* ism : arrayOfFoliageTypes) {
TArray<int32> foliageIndexValues = ism->GetInstancesOverlappingSphere(rounded_loc_cm, radius, true);
foliageIndexValues.Sort();
Algo::Reverse(foliageIndexValues);
for (const int32 foliageIndexValue : foliageIndexValues) {
ism->RemoveInstance(foliageIndexValue);
}
}