How do you set the material for an instanced static mesh with blueprint?

Hey I have similar problem the material is not applied on instanced static meshes and I don’t know 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<ATile> in it, the “TSubclassOf<ATile>” 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<ATile> 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

.cpp file

Code from Tile class

.h file

.cpp file

Material

tile blueprint

MyLevel Setting in editor

the final result

on left instanced static mesh on right Tile_BP dragged and dropped in editor

Any idea why this is happening ?

1 Like