I have an object that I would like to make blink on and off, I was able to get it to work in Blueprint just fine. But when trying to do the same with C++ it builds with no errors but when tested in the editor it crashes with no error message.
I have gone through my code and found out I am crashing anytime I try to get the material of the static mesh itself. My Code is very simple right now, but I can’t seem to figure out what I am doing wrong.
.h
UMaterialInstanceDynamic* MILight;
Inside of my function I am running this code.
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);
Any help would be greatly appreciated!