# How do I get mouse clicked position on chessboard mesh

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-mouse-clicked-position-on-chessboard-mesh/88592>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [March 27, 2017, 3:14am UTC](https://forums.unrealengine.com/t/how-do-i-get-mouse-clicked-position-on-chessboard-mesh/88592 "2017-03-27T03:14:51Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 28, 2017, 9:06am UTC](https://forums.unrealengine.com/t/how-do-i-get-mouse-clicked-position-on-chessboard-mesh/88592/5 "2017-03-28T09:06:41Z")

</div>

[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

 ![e53fc11402067dd65437d6b577993b440b201d6d.jpeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/3/e53fc11402067dd65437d6b577993b440b201d6d.jpeg)  
[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:

 ![graph.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/3/e53fc11402067dd65437d6b577993b440b201d6d.jpeg)

Make sure that your controller has _mouseover events_ enabled.  
No tracing needed, no math.

[HR][/HR]  
End result:

 ![880276341291d2d0967f3e8958e8ed8a4c75354b.jpeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/0/880276341291d2d0967f3e8958e8ed8a4c75354b.jpeg)

---

_[View the full topic](https://forums.unrealengine.com/t/how-do-i-get-mouse-clicked-position-on-chessboard-mesh/88592)._
