How do I get mouse clicked position on chessboard mesh

[QUOTE=Loucsam;686801]
I’m not sure I can count on each square (of the image material) being exactly the same width or height right across the board, even though by eye it appears uniform. I might have to do some pixel colour interrogation if we are close-ish to a border of 2 squares and make an intelligent guess or perhaps just deny the click if it is within say about 5% of the border.

[/QUOTE]

The lack of accuracy might be caused by the fact that inverse transform gives you the coordinates of the mesh counting from the very centre - this includes the Z axis. So you’re not getting the XY of the surface. If you trace from an angle, there will be an offset. You may need to account for that in the calculations. Alternatively, you could place an invisible plane on top of the board and trace against that. Or do a normal trace and simply subtract the position of the board. Many ways to do what you need.

[HR][/HR]
On the other hand, consider the following alternative:

  • every chess field is a separate actor (or component)
  • create 64, each with its own material instance


[HR][/HR]
The chess field actor:

  • cube
  • text render
  • bool isLight
  • material instance dynamic reference
  • the material is default with just one vector parameter - Colour

To interact with the field:

Make sure that your controller has mouseover events enabled.
No tracing needed, no math.

[HR][/HR]
End result: