# Get iso position using mouse position in iso grid graph

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() {
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 ?

There’s no method to do this directly. But I suppose you could get the closest node to the cursor and check the coordinates of that?

``````var node = AstarPath.active.GetNearest(position).node as GridNodeBase;
var xz = node.CoordinatesInGrid;
``````

There’s also the `transform` field on the graph which maps from graph space (where 1 unit is one node) to world space.

``````var grid = AstarPath.active.data.gridGraph;
var graphSpacePoint = grid.transform.InverseTransform(mousePosition);
``````

thanks for your response, it looks like the above works, but it looks like it sets the origin to botton edge of the grid, see video: https://youtube.com/shorts/P5r1jVRFdFM?feature=share

I can probably offset it using the grid width and height but I thought that is what the center parameter of the gridGraph was for , wasn’t it?

Hi

Internally, the origin of the graph is always in the bottom-left corner (node coordinates (0,0)). The pivot point picker in the inspector is just for convenience when editing the graph settings.