# Instanced Static Meshes render with default material

**URL:** <https://forums.unrealengine.com/t/instanced-static-meshes-render-with-default-material/359418>\
**Category:** Rendering\
**Tags:** Instanced-Mesh, unreal-engine, Scripting, Rendering, question\
**Created:** [June 2, 2016, 8:16pm UTC](https://forums.unrealengine.com/t/instanced-static-meshes-render-with-default-material/359418 "2016-06-02T20:16:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_23c91a471](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_23c91a471](https://forums.unrealengine.com/u/anonymous_user_23c91a471)\
**Post date:** [June 2, 2016, 8:16pm UTC](https://forums.unrealengine.com/t/instanced-static-meshes-render-with-default-material/359418/1 "2016-06-02T20:16:19Z")

</div>

Hey I have a problem with InstancedStaticMesh, the mesh instances are rendered with default material and I can’t figure out why

what I did is:

opened a new c++ project just basic code,  
I’ve created:

c++ Actor class “Tile”, declared UStaticMesh in it, I’ve created A blueprint from this class and set the static mesh and material, the material is created by me and it has the “Used with Instanced Static Meshes” flag set

c++ Actor class “MyLevel”, declared UInstancedStaticMeshComponent, and a TSubclassOf in it, the “TSubclassOf” member is UPROPERTY that can be edited anywhere and it is set to Tile Blueprint that I’ve created.

In "MyLevel"constructor I create instancedStaticMeshComponent, in BeginPlay() I check if TSubclassOf is set and if I set the InstancedStaticMesh-\>SetStaticMesh() and just to test I also add instance of that mesh, and now the mesh is rendered but with default material and I have no idea why. Can any one help solving this problem ?

code from MyLevel class

.h File

> **[MyLevel\_H.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211185&authkey=%21ANZi0PuM4tVWxPE&v=3&ithint=photo%2cpng)**
>
> PNG Image

.cpp file

> **[MyLevel\_CPP.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211187&authkey=%21ADpm_i-3qAiKzVE&v=3&ithint=photo%2cpng)**
>
> PNG Image

code from Tile class

.h file

> **[Tile\_H.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211184&authkey=%21ANvirlzNzWTTlNU&v=3&ithint=photo%2cpng)**
>
> PNG Image

.cpp file

> **[Tile\_CPP.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211183&authkey=%21AF5y5dopCN1oUKk&v=3&ithint=photo%2cpng)**
>
> PNG Image

Material

> **[Material.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211188&authkey=%21AAVk9YwjENxlAr8&v=3&ithint=photo%2cpng)**
>
> PNG Image

tile blueprint

> **[Tile\_BP.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211186&authkey=%21AK--0v9Cmwn3TC8&v=3&ithint=photo%2cpng)**
>
> PNG Image

MyLevel class Settings in Editor

> **[LevelSettings.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211190&authkey=%21ADm8M5Fi8XWCdBg&v=3&ithint=photo%2cpng)**
>
> PNG Image

and the result  
on left instanced static mesh with Tile\_BP blueprint, on right Tile\_BP blueprint dragged and dropped in editor

> **[Result.png](https://onedrive.live.com/redir?resid=89D22DBC98E39077%211189&authkey=%21ADUj0WUnAZ328qM&v=3&ithint=photo%2cpng)**
>
> PNG Image

Can any one tell me why this is happening ?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_23c91a471](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_23c91a471](https://forums.unrealengine.com/u/anonymous_user_23c91a471)\
**Post date:** [June 3, 2016, 12:36am UTC](https://forums.unrealengine.com/t/instanced-static-meshes-render-with-default-material/359418/2 "2016-06-03T00:36:38Z")

</div>

I’ve sorted the problem by adding a UMaterialInterface into my Tile class and loading my material in construction script than when I call AddInstance on InstancedStaticMeshComponent and get its index I call SetMaterial() passing in the instance index and the appropriate material

Update:  
Right now I only have a StaticMeshComponent in my tile class I have made a blueprint from it I set things as shown on pictures in my question but I call SetMaterial() on instancedMeshComponent passing in instance index and material of appropriate index that I get from tile class StaticMeshComponent
