Mouse Position to array

For the life of me I cannot get the mouse position to translate to my array. I have an array, it is 2d, 8x8 array, the array works fine i’ve tested that. But when I try to make the mouse position correlate I cannot get the right division or something.


That is what I have for my mouse correlation, but as I said its not working. It never puts it in the right space, and I cannot figure out why.

use Mathf.FloorToInt; you’ll get more consistent results

also y 0 means top of screen, in other words if your screen resolution is 1920*1080

mousePosition.y = 0 //Top of screen
mousePosition.y = 540 //Middle of screen
mousePosition.y = 1080 //Bottom of screen

I managed to solve the problem, the Y counted backwards to the way I thought it should be counting, So I just used a case structure to swap them around. Dirty but it works.