Create a dynamic static mesh array to change in editor view

I’m working on a blueprint to change the material of an object, pretty simple. Instead of re-doing the blueprint for each object (for example, chair, table, floor) I would like to create a single master blueprint, create instances and change only the static meshes, materials etc. Some objects are made from 1 Static mesh, others are made from several meshes. I would like to create the array on the Construction Script in order to do this for each object (for example, floor: 1 static mesh, chair: 4 static meshes) even if they are made from 1 mesh or more, and create the array making it public to add the meshes in the editor view.
I’ve found info about the “Add static mesh component” but I did not find a way to do this.
There’s any way to do it?
Thanks so much in advance for your time.

1 Like

I don’t know if this helps but you can manually populate an array with what ever you want in blueprints. Simply compile the blueprint and under the variables default value press the + next to “array elements”. You can then select the mesh you would like for each element from the corresponding drop-down menu.

If this isn’t what you are looking for I’m sure I can help if elaborate further on what you need.

Cheers,

enearle

Hey Enearle, thank you so much for your answer!.

  • Step by step:

  • I want to create a blueprint to change the materials and aspect of an object or a group of objects. For this example I want to create 2 blueprints, 1 table + 4 chairs and another one, a sofa.

  • The table + chairs have 5 static meshes. The sofa has 1 static mesh.

  • I want to create the blueprint for the material selector once, and then make an instance. Then, in the editor view change the meshes for each instanced blueprint.

  • As far as I know, I need to create an array of static meshes and then with the Set Static Mesh Node build them in the construction script.

  • The problem is, when I create the array, and after making it a public variable, I can add the meshes in the editor view, but in the blueprint it will only appear the first mesh in the array.

  • Can I set up several meshes as one static mesh?

  • There is another way to do this?

  • The goal is to add static meshes from the content browser to the blueprint and make the array and all other stuff dynamically, set up the dynamic material instances, create arrays, etc…

Maybe there is another approach completely different, I don’t know.

I hope it’s more clear now.

Again, thank you so much.

This should be relatively easy to do, I think I know what you mean. If you’re just trying to swap out objects in a scene, are your meshes static mesh actors or blue prints with static mesh children? Either way you can make references to these meshes or their parent BPs from level BP in something like the character BP at the beginning of play.

I would use the character BP because it will recognize the inputs. You can then use a specific key to change the assets, or use one key to select the thing you want to change and one to actually change it. Ultimately this you could do what ever way you want here, this is just how I’d set it up initially so you can debug it. ""Edit: You could could even use a material parameter collection to add a function to change a material’s colors or other values. “”

You could do this anyway you want I just showed you with character inputs how I would set it up. Let me know if this helps.

Hey Enearle, first of all, thank you so much for your answer.

-What I want to do is to be able to create a blueprint that can use as a public value a static mesh or multiple static meshes. I don’t want to change the mesh in run time. I want to plug in different meshes for different instances of the blueprint.

  • 1st: Create a master blueprint to control the widget creation, selector, create dynamic instances of material, etc.

  • 2nd: Create an instance of that blueprint and plug in meshes to create the selector for chair and tables, another instance of the blueprint for the sofa, another one for walls etc, and being able to do this in the editor, (and later on plug in also textures and materials to create the selector widgets depending on how much materials you have etc… that is for another question)

It’s annoying to create arrays of static meshes inside the blueprint for multiple static meshes, i would like to do it dynamically in the editor view.

I don’t konw if I’m being specific enough.

Again, thank you so much for your time. Let me know if you need screenshots of what I want to do, maybe it can help.

  • Just to clarify, in the step 01 you can see the meshes I want to add to the blueprint.
  • In the second step, there is the construction script with a public array to add the meshes in the editor.
  • Int the 3rd step, you can see the meshes being added to the blueprint, but the problem is only the last mesh in the array is shown in the viewer.

  • I’m pretty sure I’m doing this wrong. I’ve searched a lot but i found nothing…
    Again, thank you so much for your time.

Well I think I’m getting closer to what you want, the loop you’re using is just cycling through the array you made and changing the mesh associated with that instance repeatedly until it finishes. So that’s why it always turns up the last mesh in the array.

So you just want to expose a bunch of variables in the details panel of the master blueprint? Then have other blue prints look to this one for how to configure themselves in their construction scripts? Or inversely make arrays from objects of class(chair_type_1) and configure them in the construction script of the master blueprint?

This is how its set up right now let me know if I’m getting closer. XD

Thank you so much man, you’re awesome.

  • I understand what’s happening with the array, it is just I don"t know how to do it…

  • I want to create a blueprint with the the public mesh array to create instances of tha blueprint with different meshes. The master blueprint it is supposed to be empty, no mesh, just an empty blueprint to plug in different meshes after creating the instances. Sometimes one (one floor) sometimes 5 (chairs and tables).

  • I’m sorry of not being more specific, I don’t know how to explain myself. But again, thank you so much.

So what I have at the moment is you place specific class types(object1, object2, object3, etc.) they all have meshes. Then you set the meshes for each one in your master blueprint, and the construction script from the master blueprint tells them what to do.

Thanks again. I think there’s a misunderstud here. And it’s because I’m not explaining myself properly.

  • When I say Master Blueprint, I meant a blueprint I can use as template to create the other ones. That is why I want to set a public array of meshes, because in the end, the blueprint will do the same, but changing the meshes.

Sorry, I don’t know how to do what I want… thank you so much fro your help, I’ll keep trying.

Here is the answer, thanks for you help enearle, this is what I wanted to do. Thanks!

Right on, I’m happy you got there. Sorry, I couldn’t be of more help.

Thanks for your time, really appreciated to find people like you!! Thanks again!