changing static mesh material instance c++

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:

275711-1.png

add the amount of materials you will use

275712-2.png

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)]);
 }