The code failed because your asset is a UMaterial
, not a UMaterialInstanceConstant
. If your code doesn’t care about the material’s implementation details, I’d recommend instead casting it to UMaterialInterface
which would correctly work with any material, instanced or not.