# UE19.2 - SetMaterial to ProceduralMesh - cant fix it.

**URL:** <https://forums.unrealengine.com/t/ue19-2-setmaterial-to-proceduralmesh-cant-fix-it/111981>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [June 8, 2018, 9:04pm UTC](https://forums.unrealengine.com/t/ue19-2-setmaterial-to-proceduralmesh-cant-fix-it/111981 "2018-06-08T21:04:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kasi-Laubfrosch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kasi-Laubfrosch](https://forums.unrealengine.com/u/Kasi-Laubfrosch)\
**Post date:** [June 8, 2018, 9:04pm UTC](https://forums.unrealengine.com/t/ue19-2-setmaterial-to-proceduralmesh-cant-fix-it/111981/1 "2018-06-08T21:04:13Z")

</div>

Hi there,

i try to get my procedural Mesh working but currently i cant get my Material Set. I Got it in UE18.3 - so what changed?

i followed the Example here:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

and added in Header:

```auto

UPROPERTY(EditAnywhere, Category = "Materials")
        UMaterial* My_Material_Variable;

```

added in Implementation

```auto

mesh->CreateMeshSection_LinearColor(0, vertices, Triangles, normals, UV0, vertexColors, tangents, true);

    // Enable collision data
    mesh->ContainsPhysicsTriMeshData(true);
mesh->SetMaterial(0, My_Material_Variable);

```

i know that it wanted to have a MaterialInstance - but this does not change anything (both do not work 😃 ).  
Also what happened to Material.Object - seems it isnt anymore?

The header Variable works just fine and as expected, but it is not assigning the Material to Element0

i tried to put it in BeginPlay - but it crashes there. In the constructor it isnt assigning the Material.

How can i get it working? have i forgotten an include?`(but there are no compiler errors)

thanks - Johannes

---

<div class="post-metadata">

**Author:** ![Kasi-Laubfrosch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kasi-Laubfrosch](https://forums.unrealengine.com/u/Kasi-Laubfrosch)\
**Post date:** [June 12, 2018, 10:18pm UTC](https://forums.unrealengine.com/t/ue19-2-setmaterial-to-proceduralmesh-cant-fix-it/111981/2 "2018-06-12T22:18:00Z")

</div>

Thanks for “having a look” the answer is:

in header:

```auto

UPROPERTY(EditAnywhere) UMaterialInterface* Material;

```

and in Implementation:

```auto

UMaterialInstanceDynamic* DynMaterial = UMaterialInstanceDynamic::Create(Material, mesh);
//set paramater with Set***ParamaterValue
DynMaterial->SetScalarParameterValue("MyParameter", 1.0);
mesh->SetMaterial(0, DynMaterial);

```
