Static Mesh arrays in Blueprints, Reference or Asset ID?

I have some questions regarding the use of Static Mesh References/Asset ID for storing available meshes in an array to pick from in a Blueprint.

Basically, we have lots of different groups of objects we use in every level. Each group of objects has anywhere from 2 to 10 different versions of that particular object type. All versions of that object need the same functionality, for example, they all use the same master material and all behave the same way, the only thing that changes is the actual mesh.

With that in mind, I created a “Master Blueprint” with all the functionality that every group of object has by default, and I am using that as the parent class for each “Child” blueprint created per object group. Each Child blueprint adds its own functionality based on the object group type is was made for.

The Master blueprint has an array of Static Mesh Reference populated with all the different Mesh versions for that object group, and an index to choose which mesh to use. If I understand correctly, does that mean that each duplicate of that blueprint always loads all the meshes defined in the array, and only displays the 1 retrieved with the index? If that’s true, then this seems very inefficient, especially if we have several hundreds in the level.

Would using an array of Static Mesh Asset ID a better solution? What’s the best practices for situations like this?


Your assumption is correct. Hard references (basically any blue node or variable, or purple class node or variable) mean the object is loaded in memory automatically, and this is also true for anything that references the object that contains the reference.

Blueprint1 has an array of Static Mesh references containing Mesh1, Mesh2, Mesh3.

If Blueprint1 is in the world, Mesh1/2/3 are all loaded with it.

If Blueprint2 references Blueprint1 (say Blueprint2 has a Spawn Actor node with Blueprint1 as the class), and Blueprint2 is in the world, Blueprint1 and Mesh1/2/3 will be loaded along with Blueprint2.

Asset IDs and Class IDs exist for that reason. That’s why you have 4 choices when you create a variable of a certain type (Object Reference, Class Reference, and then an “unloaded” version of each). They hold a reference to the asset as a string (in the back end), and must be loaded before they can be accessed.

When you Load an asset ID, what comes out will be of type Object, so you’ll need to cast it to Static Mesh in order to then plug it into whatever you’re using the mesh for.

Hey JParent, thx for the quick reply.

Ok so it looks like Asset ID is the way to go, but is it safe to assume that an Asset ID might not always return a valid reference in a Construction Script? I tried setting up my meshes array using Asset ID, and some of the meshes appear, and some don’t until I either load the mesh in the StaticMesh Editor by double-clinking on it, or if I right-click the mesh, and click “Copy Reference”. Only then do they show up in the editor.

You can’t load assets that way in a construction script because it’s a latent action. If you need to see the static meshes in your blueprint in-editor, then you could just set them up with normal static mesh references, but then use asset IDs for the Blueprints that contain those meshes and load those asynchronously instead.

Ok that’s what I thought.

Thanks for the help!