Support Forum

Path Position Issue

I’m trying to get a path for a Grid Graph using AstarPath.StartPath, but it is returning very large positions (Path.path[index].position). Node size is 1 on a 10 by 10 grid and a search from 0,0,0 to 1,1,0 returns the following path list:

500,500,0
1500,1500,0

I was hoping for something like this:

0,0,0
1,1,0

Hi

Node positions are stored as integer coordinates in millimeters. You can convert them to regular Vector3 coordinates using a cast.

Vector3 p = (Vector3)node.position;

You can also access their indices in the grid:

var gridNode = node as GridNodeBase;
int x = gridNode.XCoordinateInGrid;
int z = gridNode.ZCoordinateInGrid;