I have code that calculates where the user clicked inside an iso tile in an isometric map. The tile has a width of 1 unit and a height of 0.5 units. My code calculates where they touched inside the tile in these same units. The goal is to then decide where that click falls if you sub-divided the iso tile into a 4x4 grid. The picture below shows how all this is supposed to look.
I have found ascreen co-ordinates to iso formula and it makes sense but for whatever reason, when I try to use it with my data above I get wrong outputs. When clicking from the top corner to the right corner, only the X iso output should change but both the X and the Y change.
I feel like this should be pretty simple but after hours of banging my head against this I can't figure out what I am doing wrong.
Source for screen to iso formula: How would I translate screen coordinates to Isometric coordinates?
Any help would be greatly appreciated.
float touchedX; float touchedY; //below 0.125 represents the tile height because the whole thing // is 0.5 and its 4 tiles high so 0.125, 0.5 is 2*width which //is (1 / 4.0) * 2 float gridPointLedftDown = (touchedY / 0.125f) + (touchedX / 0.5f); float gridPointRightDown = (touchedY / 0.125f) - (touchedX / 0.5f);