Using CreateAndSetMaterialInstanceDynamic on a procedural mesh

Hi!

I am attempting to apply a dynamic texture (as according to The mesh itself works, but i am having trouble applying the dynamic material to the mesh.

as indicated by the text log i get after the engine crashes, the problem can be narrowed down to this specific line of code:

dynMaterialInstances.Add(mesh->CreateAndSetMaterialInstanceDynamic(0));

With the text log entry:

[2018.03.28-09.36.20:313][ 40]LogPrimitiveComponent: Warning: CreateAndSetMaterialInstanceDynamic on /Game/StarterContent/Maps/UEDPIE_0_Minimal_Default.Minimal_Default:PersistentLevel.DynamicActor_0.GeneratedMesh: Material index 0 is invalid.

Since i have not been able to find any information on the use of dynamic textures with a procedural mesh, I am not sure how i can solve this problem. Is there something specific that changes what material index the procedural mesh uses? And if so, what index might this be?