Download

How to access the mesh instances of an InstancedStaticMeshComponent in a BP

Hi guys

I have a set of blueprints which contain a few “InstancedStaticMeshComponent” components. In the details tab of said component, I then create the instances I need.

My question now is: how can I access the instances individually in the construction script of the BP (I need to assign separate materials to each mesh instance)?

Cheers,
Michael

As I understand it, you have no way to target an instance after it was instantiated. It ‘melts’ together with the other instances. Also, all instances always have the same properties as the source part. I experimented with instances and found it especially frustrating that all instances change their LOD in respect to the common center of all instantiated parts. Also culling, once triggered, hides all instances at once, no matter how far they are away.

Oh my, that’s actually quite a killer for using instances in my case then. I will have to revert to full copies of the meshes to get it working…

Not necessarily. Read through the thread below where the Dev Ian Shadden gives a good method of using Instances but keeping interactivity:

https://forums.unrealengine.com/showthread.php?3454-Map-Generator-Please-Critique!

Basically you spawn collision volume actors with your instances that handle collision events and everything that comes with that. I use it and it works quite well. It at least keeps me down to a few dozen draw calls instead of tens of thousands.

@Zeustiak: Thanks for the hint. I’ll have a look at it (I remember following that thread ;). I don’t have as many instances, I’m at 6-12 per BP and around 150 per level. Let me give your approach a shot, though.

You may not need to instance in your case, but if it feels a little slow for no good reason then instancing may help you out. :slight_smile:

I’m keen on optimization so I’ll go with instancing wherever possible :wink:

By the way, I have come up with a solution using PerInstanceRandom logic in my materials - works perfectly for what I needed :slight_smile: