Hey ,
I took a look at your code and I think the error you are running into is potentially an infinite loop error. In this code:
for (int j = ProductRows[i].Products.Num() - 1; j >= 0; j--)
{
CullXRow(ProductRows[i].Products[j]);
}
}
You are passing in information that when this is run:
void AProductGroup::CullXRow(FProductRowX &RowToDestroy)
{
// Determine if should add or remove products // This one removes
if (RowToDestroy.Products->GetInstanceCount() > ProductPlacementX)
{
for (int i = RowToDestroy.Products->GetInstanceCount() - 1; i >= ProductPlacementX ; i–)
{
UE_LOG(LogTemp, Warning, TEXT(“Destroyed Product: %d”), i);
RowToDestroy.Products->RemoveInstance(i);
}
}
// This one adds
else if (RowToDestroy.Products->GetInstanceCount() < ProductPlacementX)
{
FVector meshOrigin;
FVector meshExtent;
float sphereRadius;
UKismetSystemLibrary::GetComponentBounds(ArrowMesh, meshOrigin, meshExtent, sphereRadius);
for (int i = RowToDestroy.Products->GetInstanceCount(); i < ProductPlacementX; i++)
{
int asdf = RowToDestroy.Products->AddInstance(FTransform(FVector(meshExtent.X + (((meshExtent * 2).X + GapBetweenProducts)*i), 0, 0)));
UE_LOG(LogTemp, Warning, TEXT("Created Product: %d"), asdf);
}
}
}
It is constantly changing. Because of how it is checking to see if j>=0 and looking for Row information that may be rapidly both adding and subtracting information, it may be running into an infinite loop, which would result in a crash.