Quick answer: Create a MID with CreateDynamicMaterialInstance(slot), keep the returned pointer, and call SetScalarParameterValue on that pointer. Setting on the base material or a static instance does nothing. Verify with a GetScalarParameterValue round-trip.
Here is how to fix Unreal Material Instance Dynamic not updating. You want each enemy to glow red when damaged. You get the material on the mesh, call SetScalarParameterValue, and the material does not change. Other enemies also change together, or none do. Dynamic Material Instances require a specific lifecycle to work correctly.
The Symptom
SetScalarParameterValue or SetVectorParameterValue calls have no visual effect on a mesh. Or the effect applies to every mesh sharing the material rather than only the one you targeted. GetScalarParameterValue afterward returns the set value — so the write worked somewhere, just not on the rendering material.
What Causes This
Writing on base material. Materials are assets. Every mesh sharing a material literally shares the same asset. Writing a parameter on the asset affects every mesh or, more commonly, is ignored at runtime because base materials are not meant to be runtime-editable.
Static material instance. A Material Instance (MI) created in the editor is a static asset too. Runtime writes on an MI are silently ignored — only a Dynamic Material Instance (MID) allows runtime parameter changes.
MID not assigned back to component. Calling CreateDynamicMaterialInstance returns the MID and assigns it to the slot. But if you use UMaterialInstanceDynamic::Create (the static function) without assigning to a component, the MID exists but nothing renders with it.
Wrong component method. StaticMeshComponent has CreateDynamicMaterialInstance(slot). SkeletalMeshComponent has the same. PrimitiveComponent has a general version. Using the generic one without specifying the slot can fail for multi-material meshes.
The Fix
Step 1: Create MID correctly.
// MyActor.h
UPROPERTY()
UMaterialInstanceDynamic* DynamicMaterial;
// MyActor.cpp
void AMyActor::BeginPlay()
{
Super::BeginPlay();
DynamicMaterial = MeshComponent->CreateDynamicMaterialInstance(0);
if (!DynamicMaterial)
{
UE_LOG(LogTemp, Error, TEXT("Failed to create MID"));
}
}
void AMyActor::SetGlowIntensity(float Value)
{
if (DynamicMaterial)
{
DynamicMaterial->SetScalarParameterValue(
TEXT("GlowIntensity"), Value);
}
}
CreateDynamicMaterialInstance(0) creates a MID for material slot 0, assigns it to the component, and returns the pointer. Store it in a UPROPERTY so GC does not destroy it.
Step 2: Verify parameter name exists. Open the parent material. Find the ScalarParameter node with name “GlowIntensity.” Parameter names are FNames and case-insensitive in lookup but typos produce silent no-op.
void AMyActor::VerifyParam()
{
float Current = 0;
if (DynamicMaterial->GetScalarParameterValue(
TEXT("GlowIntensity"), Current))
{
UE_LOG(LogTemp, Log, TEXT("GlowIntensity = %f"), Current);
}
else
{
UE_LOG(LogTemp, Error, TEXT("Param not found"));
}
}
GetScalarParameterValue returns false if the param name does not exist on the material.
Step 3: Apply per material slot. For meshes with multiple materials:
int32 NumSlots = MeshComponent->GetNumMaterials();
for (int32 i = 0; i < NumSlots; ++i)
{
UMaterialInstanceDynamic* Mid = MeshComponent->CreateDynamicMaterialInstance(i);
if (Mid)
{
Mid->SetScalarParameterValue(TEXT("GlowIntensity"), 1.0f);
}
}
Create a MID per slot that needs parameter changes. Each slot gets its own MID.
Step 4: Keep MID alive. Store the MID pointer in a UPROPERTY to prevent garbage collection. If the MID is freed, writes to a stale pointer do nothing (and may crash).
Blueprint Pattern
Blueprints: call Create Dynamic Material Instance on the mesh component, store the result in a variable, then call Set Scalar Parameter Value on that variable. Common mistake: calling on the mesh directly, which creates but does not store, so the next frame has no reference.
Sharing vs Per-Instance
If many enemies should glow identically, a single MID shared among them is fine. If each enemy has independent glow (damage flash), each needs its own MID. CreateDynamicMaterialInstance per enemy ensures per-instance state.
“MID is a per-instance material. Without it, you cannot change parameters at runtime. Create it, store it, call on it.”
Related Issues
For global parameter collections, see Material Parameter Collection Not Updating. For replication-related material issues, Actor Replication Not Working.
CreateDynamicMaterialInstance, UPROPERTY the pointer, SetScalarParameterValue on it. Three steps.