Hello community ![:slight_smile: :slight_smile:](https://d1ap1mz92jnks1.cloudfront.net/images/emoji/twitter/slight_smile.png?v=12)
I’m currently doing this to make changes to the material of my decal from c++ :
toAdd->Decal->SetDecalMaterial(Material);
auto dynamic = toAdd->CreateDynamicMaterialInstance();
dynamic->SetScalarParameterValue(TEXT(“Rotator”), FRandomStream().RandHelper(360));
dynamic->SetVectorParameterValue(“Color”, FLinearColor(0, 0, 1));
But it has no effect. What am I doing wrong ?
Thanks for your answers !
Just creating is not enouth, you need to set that instance as one currently active, so use CreateAndSetMaterialInstanceDynamic instead
CreateAndSetMaterialInstanceDynamicFromMaterial if you want to use 2nd argument
The problem is that I want to use it with a decal. So I can’t use the function found in UPrimitiveComponent.
But you where right about setting the instance. So what I did is :
auto dynamic = toAdd->CreateDynamicMaterialInstance();
dynamic->SetScalarParameterValue(TEXT(“Rotator”), FRandomStream().RandHelper(360));
dynamic->SetVectorParameterValue(“Color”, FLinearColor(0, 0, 1));
toAdd->SetMaterial(0, dynamic);
Thank you ![:slight_smile: :slight_smile:](https://d1ap1mz92jnks1.cloudfront.net/images/emoji/twitter/slight_smile.png?v=12)