Getting instanced static mesh component from actor

So I wrote a simple blueprint that constructs a building using 3 instanced static meshes, the meshes are: a cube, a glass cube and a half cube. Now I want to detect which of the 3 I hit with a line trace. I know how to get the index of a mesh, but not which mesh I hit. I tried using the “Hit Component” output of the trace but it is not compatible with “Instanced Static Mesh Component Reference” as it is a “Primitive Component Reference”.

EpEp

Would also like to know how this can be done.

Have you found a solution to this?

It’s been a while since I’v looked at this particular problem. From what I can remember it’s not possible to delete one component of the instanced static mesh without deleting the whole. I might be wrong about this presently.

So I ended up using a voxel system that uses the procedural mesh component to generate the terrain, or whatever. And you can delete/add individual voxels. If you’re not familiar on how to implement voxels then this is a good starting point. The tutorial is focused on terrain application, but the voxel system is the same for buildings and whatnot, you just use a building algorithm or manually input the voxels instead of using noise. The tutorial is a bit old, but I can confirm that it works with new engine versions, there are some bits of code that needs changing, but that’s addressed in the comments section.

Just read my question and it seems like this is not quite the one I thought it was, sorry. However what I said about voxels still stand, it seems easier to do it that way.

This answer is even better than what I expected, thanks a lot!

No problem, I sure was surprised to see a notification of my almost 3 year old question pop up :slight_smile:

Well, since people are still looking at this thread–and it just came up for me in a search for something else–I figure I might as well toss my solution on here in case anyone finds it useful. If I understand the question right, I think you just need to cast to the instanced static mesh, and in conjunction with “Hit Item” that should give you the specific instance that you hit. So, for example, you could remove the specific instance (and not the whole thing) like this:

1 Like

Use a “Cast To instancedStaticMeshComponent” node, then the “As Instanced Static Mesh Component” output will give you the instanced static mesh component reference that you can plug into various instance static mesh related nodes.

,I’m having sort of the same problem. I know it can probably be solved by using a “get display name” node and then comparing the name to the name of the “instanced static mesh component” 's name, but that seems a bit clumsy to me.

Use a “Cast To instancedStaticMeshComponent” node, then the “As Instanced Static Mesh Component” output will give you the instanced static mesh component reference that you can plug into various instance static mesh related nodes.

Is there any reason why this approach may not work? I’m trying to do the same thing(Just remove the HISM that is hit in the array but leave the rest).

Not working. HitItem is always -1.