Unable to change material colour

Hi,

I am unable to change my material’s colour on the fly and not sure why.

Here’s my code, it’s pretty simple:
.h

UMaterialInstanceDynamic*
GlovesMaterialInstanceDynamic;

.cpp

UMaterialInterface* MeshMat =
Mesh1P->GetMaterial(0);

GlovesMaterialInstanceDynamic =
UMaterialInstanceDynamic::Create(MeshMat,
this);

GlovesMaterialInstanceDynamic->SetVectorParameterValue(FName(TEXT(“Color”)),
FLinearColor(2.0,0.0,0.0,1.0));

My material has a vector parameter called Color in it’s emissive and basecolor inputs.

Am I missing something super simple here?

Thanks,

Jon

You need to assign your dynamic material instance to the mesh. So after creating it:

Mesh1P->SetMaterial(0, MeshMat);

We have a convenience function to override and set the dynamic material instance as it is a common pattern. So you could instead do:

GlovesMaterialInstanceDynamic = Mesh1P->CreateAndSetMaterialInstanceDynamic(0);

Ah great! Thanks Nick.