I have set up some Destructible meshes to switch their material after a timeout from their original opaque material to a translucent fading material.
/* This is a wrapper for UMaterialInstanceDynamic::Create that copies parameter values from the given Material Interface to a new Dynamic Material */
UMaterialInstanceDynamic* FadeInstance = UTLMaterialUtils::CreateDynamicMaterialOfType(MatInterface, FadeMaterial, this);
/* I expected this to work in the same way as it does for a static mesh, and although the material is visible in the material overrides list, only the default worldgrid material is visible on the chunks */
As mentioned in the code comments, when using SetMaterial, the override is set, but it does not render on the chunks. Instead I see the default WorldGrid material.
Is there a different way I should be assigning material overrides to destructible chunks?
I had to work on this on my very first project, I did something like:
UPROPERTY(EditDefaultsOnly, Category = "Material")
DefaultMaterialInst = DefaultMaterialObj.Object;
// Assigning the material on an update material function
DynamicInstance = UMaterialInstanceDynamic::Create(DefaultMaterialInst, this);
The only difference is that I’m taking the material instance BP and creating a new material instance with it, then assigning it to the pos 0 and 1 of the DM, to be honest I cannot remember why I used index 0 and 1. Hope this helps.