Getting instanced static mesh by index in BP?

Hey. I’m quite new to unreal, and having some issues with my experiment project.

I have some foliageinstancedStaticMeshComponent that i would like to highlight when pointing at with mouse cursor.

Currently i’m using Get Hit Result Under Cursor by Channel, breaking hit result and then Set Render Custom Depth to highlight with a post process material. The problem is that this will highlight all instances of the same mesh, rather than individual Meshes. I get the index from hit item in the hit result, but can’t find a way to use it to get the correct mesh.

I know that the hit result is correct, because i’m using it to Remove Instance with mouse click, and the correct Mesh will be removed.

I did see that Set Custom Data Value will allow me to pass the index to the material, but as i don’t want to customize the materials for every possible item, but rather use the highlight through Set Render Custom Depth i don’t really know how to move on. Any Ideas?

I’m no expert on this, but I think this route won’t work, because all instances are basically one mesh.

A very common approach with this sort of thing ( felling trees etc ), is when the player selects the object, to replace it with a normal static mesh or blueprint.

That’s something you can work with.

Dear @Celtharius ,

Set Render Custom Depth operates on the entire component, so while you are correct to obtain the index for isolating individual instanced static mesh… instances… the issue is that your next action applies to the entire component.

:heart::heart::heart: @ClockworkOcean :heart::heart::heart: has the correct solution!

Use the index value you acquired, to get the transform information, remove the instance,

And spawn a regular tree/bush/flower/rainbow-haired-unicorn-favorite-snack-plant :rainbow: :unicorn: with the same world transform position.

Now you can use Set Custom Render Depth and you will get just that tree highlighting!

:zap: Victory! :zap:

:heart:

Rama

PS: @ClockworkOcean I couldn’t resist the opportunity… 'specially since you started the whole thing with that pic you pm’ed me one time…

1 Like

:smiley:

unicorn

1 Like

Thank you guys. That makes sense :slight_smile: Really appreciate the replies!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.