I’m trying to destroy all the elements of an array of spline mesh components using a for loop to destroy each mesh but every time it enters the array, the editor crashes and tells me: Array index out of bounds : 16 from array of size 16(The size of the array will be changing at runtime so I can’t create a static array). I appreciate any help on what is the proper way of doing this task. Note I have tried setting index to just the array’s Num() without the -1. But this does not fix the issue either.
void ControllerItem::ClearArc()
{
if (splineMeshes.Num() > 0)
{
for (int32 index = splineMeshes.Num() - 1; index > 0; index--)
{
splineMeshes[index]->DestroyComponent();
}
splineMeshes.Empty();
ArcSpline->ClearSplinePoints(true);
}
}