it would be much easier to create it in this way, creating a list of materials:
UPROPERTY(EditAnywhere, Category = "List Materials")
TArray<class UMaterialInterface*> ListMaterial;
results:
add the amount of materials you will use
this would look at the size of the list a random material
–
if (ListMaterial.Num() > 0)
{
"YourStaticMesh"->SetMaterial(0, ListMaterial[FMath::RandRange(0, ListMaterial.Num() - 1)]);
}
–