Hexagonal Grids, how do you find which hexagon a point is in?

前端 未结 8 716
不知归路
不知归路 2020-12-07 15:14

I have a map made up of rows and columns of hexagons\"\"

This isn\'t an actual image of the hex-map I am using,

8条回答
  •  悲&欢浪女
    2020-12-07 15:43

    I found a different way to see if the mouse is in a hexagon. Using a bit of trig you can find the angle of the line between the mouse and the centre of the hexagon, using this angle you can work out how long the line would be from the centre of the hexagon to the edge of the hexagon at that angle. Then just check the length of the line between the mouse is less than the expected length to the edge of the hexagon. If anyone wants an example code i can share.

提交回复
热议问题