[Question]Edit Material Parameters C++

Dear Tyler,

Please post your code where you are setting Lamp pointer properly.

Most likely your Lamp is not valid reference

to test this, modify your code as follows, probably you will not get a crash but still nothing will happen, because you are not setting the Lamp reference properly.

if(!Lamp) return;
//~~~~~~~~~~~~

UMaterialInstanceDynamic* MILight = UMaterialInstanceDynamic::Create(Lamp->GetMaterial(0),this); // This is where I appear to be crashing at.
 
MILight->SetVectorParameterValue(FName(TEXT("LightColor")),FLinearColor(0.0,0.0,0.0,1.0);
 
Lamp->SetMaterial(0, MILight);
1 Like