# StaticMeshComponent, material replication

**URL:** <https://forums.unrealengine.com/t/staticmeshcomponent-material-replication/443787>\
**Category:** Asset Creation\
**Tags:** Replication, staticmeshcomponent, unreal-engine, CPP, question\
**Created:** [February 20, 2019, 6:31pm UTC](https://forums.unrealengine.com/t/staticmeshcomponent-material-replication/443787 "2019-02-20T18:31:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SvarogZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SvarogZ](https://forums.unrealengine.com/u/SvarogZ)\
**Post date:** [February 20, 2019, 6:31pm UTC](https://forums.unrealengine.com/t/staticmeshcomponent-material-replication/443787/1 "2019-02-20T18:31:59Z")

</div>

New StaticMeshComponent is created dynamically during the game.  
For the Server, everything works perfectly.  
However, for the Client, everything replicates (scale, location, rotation) excluding the material.

If I change to

```
StaticMeshComponent->GetStaticMesh()->SetMaterial(MaterialId, MaterialInstance);

```

The material is setting and replicates for all Static Meshes on the level

How I can set material for a StaticMeshComponent to have it on the Client as well?  
It’s not clear for me why just material is not replicated.

```
UStaticMeshComponent* StaticMeshComponent = NewObject<UStaticMeshComponent>(this);

if (!StaticMeshComponent) { return; }

StaticMeshComponent->RegisterComponent();
StaticMeshComponent->SetStaticMesh(BuldingMesh.GetMesh());
StaticMeshComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
StaticMeshComponent->SetRelativeTransform(BuldingMesh.GetShapeTranform());

UMaterialInstanceDynamic * MaterialInstance = StaticMeshComponent->CreateDynamicMaterialInstance(0, BuldingMesh.GetMaterial());

if (MaterialInstance)
{
	StaticMeshComponent->SetMaterial(MaterialId, MaterialInstance);
	//StaticMeshComponent->GetStaticMesh()->SetMaterial(MaterialId, MaterialInstance);
}

StaticMeshComponent->SetIsReplicated(true);
```
