Download

Hit testing ("picking") mesh instances

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://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?

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

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!