Download

[Arrays] How do i find the index of the static mesh in my array from the location of my mouse click?

I have created a hex based grid and want to make something move to the hexagon that is clicked, how do i do this??

Once approach maybe:

  1. Add a ‘Tag’ to every static mesh. Add all the meshes to an array.
  2. Use Deproject-Screen-To-World to get a distant 3D ‘Target’ point from 2D mouse.
  3. Do a Line-Trace between center-screen and this 3D target point (2d-mouse point)
  4. If you hit something, get the Tag (if one exists) for the hit actor or mesh etc.
  5. Use that to iterate through the array via string comparison. If found store the index!