# Hit testing ("picking") mesh instances

**URL:** <https://forums.unrealengine.com/t/hit-testing-picking-mesh-instances/37793>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [August 6, 2015, 11:46pm UTC](https://forums.unrealengine.com/t/hit-testing-picking-mesh-instances/37793 "2015-08-06T23:46:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelWion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MichaelWion](https://forums.unrealengine.com/u/MichaelWion)\
**Post date:** [August 6, 2015, 11:46pm UTC](https://forums.unrealengine.com/t/hit-testing-picking-mesh-instances/37793/1 "2015-08-06T23:46:26Z")

</div>

I know this must be possible, but I can’t figure out the proper way to achieve it.  
In a 3rd person project, I’m trying to project a raycast/trace from the camera, through the player, onto a mesh instance, and _ **return the index of the mesh instance that was hit** _, if any.  
Here’s a video demonstrating one of my _many_ attempts at accomplishing this…  
(You might need to watch it on youtube in fullscreen to get a clear image)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/a/bfafa3a4c5efd4cd0cbd90d09376343e9f93f4b5.jpeg "Instanced Static Mesh (Hit Testing/Picking)") ](https://www.youtube.com/watch?v=5i-LsTTHiHI)

As you can see, I have the hit testing part working just fine, and I feel I am very close to success.  
And I realize the code isn’t perfect, but I’ve tried various methods and can’t seem to solve the problem of getting which instance was hit.  
Does anyone have any idea how to achieve this?

---

<div class="post-metadata">

**Author:** ![JmDevTx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JmDevTx](https://forums.unrealengine.com/u/JmDevTx)\
**Post date:** [August 7, 2015, 12:08am UTC](https://forums.unrealengine.com/t/hit-testing-picking-mesh-instances/37793/2 "2015-08-07T00:08:54Z")

</div>

The ‘Hit Item’ return pin on the hit result is the index of the hit instance.

---

<div class="post-metadata">

**Author:** ![MichaelWion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MichaelWion](https://forums.unrealengine.com/u/MichaelWion)\
**Post date:** [August 7, 2015, 12:23am UTC](https://forums.unrealengine.com/t/hit-testing-picking-mesh-instances/37793/3 "2015-08-07T00:23:34Z")

</div>

Holy hell… I tried that previously, and for whatever reason, it always returned 0…  
But I did it again just now and it worked! Thanks!
