RealDocs

UKismetMaterialLibrary::CreateDynamicMaterialInstance

function Engine Blueprint Since unknown
#include "Kismet/KismetMaterialLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallable

Description

Creates a new Material Instance Dynamic (MID) from a parent material, allowing its parameters to be changed per-object at runtime.

Caveats & Gotchas

  • Each call allocates a new UMaterialInstanceDynamic — calling this repeatedly (e.g. every tick) creates unnecessary GC pressure; create it once and cache the reference, then call Set*ParameterValue on that instance.
  • The returned MID is not automatically applied to any component — you still need to call SetMaterial (or the equivalent mesh/component API) to render with it.
  • EMIDCreationFlags::Transient marks the MID as a transient object so it's excluded from saving/duplication, which matters for instances created purely for runtime-only effects.

Signature

static ENGINE_API class UMaterialInstanceDynamic* CreateDynamicMaterialInstance(UObject* WorldContextObject, class UMaterialInterface* Parent, FName OptionalName = NAME_None, EMIDCreationFlags CreationFlags = EMIDCreationFlags::None);

Parameters

Name Type Description Default
WorldContextObject UObject* World context used when creating the instance.
Parent UMaterialInterface* The material or material instance to base the new dynamic instance on.
OptionalName FName Optional name for the created object. NAME_None
CreationFlags EMIDCreationFlags Bitflags controlling how the instance is created, e.g. marking it Transient. EMIDCreationFlags::None

Return Type

UMaterialInstanceDynamic*

Example

Create and apply a runtime material instance C++
UMaterialInstanceDynamic* MID = UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, BaseMaterial);
MID->SetScalarParameterValue(TEXT("Damage"), 0.5f);
MeshComponent->SetMaterial(0, MID);

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.