Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

    I've tried using set material on the instanced static mesh component in blueprint. I've tried choosing the material for the instanced static mesh in the components list. Whatever I try, the mesh is always shown with the default material. maybe there's only a specific type of material that works with instances, or maybe you have to use a specific setting somewhere to make it use the material? I've been looking all over the forums and can't find any example of doing this. Can someone show me an example of how make an instanced static mesh use a material? or a link to an example?

    #2
    HI

    Look from about 15:00 onwards



    It shows how to change the color of a mesh when it gets hit.

    Narg
    http://www.seven-mountains.eu/

    Comment


      #3
      I don't think he uses instanced static meshes in that.

      Comment


        #4
        Hello,
        Except if something has changed recently : sadly, you can't, i did some tries too and could change all of them only : https://answers.unrealengine.com/que...ters-on-i.html
        Only an idea on the fly i would try in your situation to have benefit of instances, not sure it would work : Create two bp with ISM with both materials, when needed, get location, destroy the first, add instance to the other in location. (maybe with an array to register location)

        Comment


          #5
          I believe the only thing that can change between instances is transform since they are all part of the same component. When you add an instance to an ISMC you're expanding the original ISMC. When you add a new StaticMeshComponent, it's a whole new component.
          iTween For UE4
          Procedural pathed animation for actors, components & UMG - $0
          Runtime DataTable
          DataTables dynamically loaded from text or Google Sheets while your game is running!
          easyCSV
          Fast, cheap, and accurate CSV parsing at runtime!

          Comment


            #6
            I was trying to figure out how to get them to show up at all. in the first place. The answer is, you have to check "Used with Instanced Static Meshes" in the material properties. This was something simple I couldn't find anywhere. I actually had all the advanced parts figured out but I was unaware of that one little setting. Lame. For anyone else trying to figure out how to use them, watch this video https://www.youtube.com/watch?v=mI7eYXMJ5eI

            Comment


              #7
              We all misunderstood your question, sorry. I thought you tried to change the material of one instance, during runtime.

              Comment


                #8
                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
                Click image for larger version

Name:	MyLevel_H.png
Views:	1
Size:	99.8 KB
ID:	1107558

                .cpp file
                Click image for larger version

Name:	MyLevel_CPP.png
Views:	1
Size:	108.1 KB
ID:	1107569


                Code from Tile class

                .h file
                Click image for larger version

Name:	Tile_H.png
Views:	1
Size:	137.4 KB
ID:	1107568

                .cpp file
                Click image for larger version

Name:	Tile_CPP.png
Views:	1
Size:	93.1 KB
ID:	1107570



                Material

                Click image for larger version

Name:	Material.png
Views:	1
Size:	500.6 KB
ID:	1107564


                tile blueprint

                Click image for larger version

Name:	Tile_BP.png
Views:	1
Size:	449.6 KB
ID:	1107571


                MyLevel Setting in editor

                Click image for larger version

Name:	LevelSettings.png
Views:	1
Size:	909.0 KB
ID:	1107566


                the final result

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

                Click image for larger version

Name:	Result.png
Views:	1
Size:	531.8 KB
ID:	1107572


                Any idea why this is happening ?
                Attached Files

                Comment


                  #9
                  I had the exact same problem, and this was the answer for me:
                  https://answers.unrealengine.com/que...ough-code.html
                  ->"set "Use with Instanced static Meshes" in the material setup"

                  Comment

                  Working...
                  X