I have a iso metric grid graph with the following values
I want to map the mouse position to the iso grid node position something like:
This is how I am trying to do it :
private void debugCurrentNode() {
float mouseX = Mouse.current.position.x.ReadValue();
float mouseY = Mouse.current.position.y.ReadValue();
Vector2 curMouseWorldPos = Camera.main.ScreenToWorldPoint(new Vector3(mouseX, mouseY, 0));
Debug.Log("ISO POSTION:" + XYToIso(nNInfo.position));
}
Vector3 XYToIso(Vector3 v) {
float nodeSize = MapManager.Instance.aStarGridGraph.nodeSize;
Vector3 normalizeToNodeSize = v * nodeSize;
// not sure how to use this
float angle = MapManager.Instance.aStarGridGraph.isometricAngle;
float isoX = normalizeToNodeSize.y + normalizeToNodeSize.x;
float isoY = 0.5f * (normalizeToNodeSize.y - normalizeToNodeSize.x);
return new Vector3(isoX, isoY, 0);
}
but it ain’t giving me the result , won’t lie ,I don’t really understand the math but been doing a trial and error thing ,also is there something in the library itself I can use to achieve ?