How to create meshes in construction script from folder in BP?

Hello,

How can I add, within the construction script, a mesh that I could find from a folder?

For example, I want to add this mesh in my construction script:
/Game/Props/Object001

How can I do that?

Thank you!

Hi Shelby,

You will want to use a “Add Static Mesh Component” node. There will be a dropdown option on the node that will allow you to pick a static mesh from your content browser. Let me know if that helps.

Cheers,

Thank you for your answer,

I have a string variable storing the path of the mesh I want to spawn.
The variable can contain more than 50 different paths so doing a switch on all these values won’t be really efficient…

Could you explain more about what you are trying to accomplish? Using a String to determine a path for an object is not a default function in Blueprints. You could code a custom node to do that though. There are many ways to swap 50 or more meshes, but that all depends on how you would like it to function.

Are the meshes something procedural and random, or would a level designer just need an easy way to swap between them? Can you give an example of something similar?

Does the construction script erase all created components when refiring or do I have to do that manually?

Yes it does.
From my own testing, GetNumChildrenComponents on the root component return 0 (i.e. all created components are erased) every time I compile the blueprint.

Hi,

Shelby
I have the same issue, did you ever find a solution to this?