I’m learning how to use dynamic material instances on procedural meshes and I’ve got myself a bit stuck.
Basically I have a line in my actors OnConstruction method doing this:
edenTestMaterialInstanceDynamic = UMaterialInstanceDynamic::Create(testPlane->GetMaterial(0), this);
( and I setup the var in the actors header with UMaterialInstanceDynamic* edenTestMaterialInstanceDynamic; )
It works first time, but after that it fails with this error message:
LogMaterial:Warning: MaterialInstanceDynamic /Game/Core/Maps/Test_planet_level.Test_planet_level:PersistentLevel.edenPlanet_11.MaterialInstanceDynamic_38 is not a valid parent for MaterialInstanceDynamic /Game/Core/Maps/Test_planet_level.Test_planet_level:PersistentLevel.edenPlanet_11.MaterialInstanceDynamic_39. Only Materials and MaterialInstanceConstants are valid parents for a material instance.
Makes sense, it can “upgrade” the original material to a material instance, but it can’t then upgrade the new material instance to another material instance.
What I haven’t been able to figure out is how to check if the material in testPlane->GetMaterial(0) is a material or a material instance Any tips?