Ok so I have implemented A* pathfinding on a isometric Y as Z tilemap. I use the algorithm to make a Stack which is my path, then I peek the first item an move towards it. Once there or basically there (I am using a distance check to see when I am very close (0.005f) to my destination) then I set my position as the target position, pop the stack and loop. I loop until the stack(path) is empty. This all works as expected but while moving my player the travel speed between tiles is either normal (what I expect) along the x axis, or almost instantaneous when traveling along the y axis. Just to be extra clear when I say X axis, it is the GRIDS x axis. As this is an isometric y as z map the x axis is diagonal (upper left to lower right) and the y axis is the opposite (lower left to upper right). I am using this code to do the move…
public void Move()
{
if (path.Count > 0)
{
Vector3Int target = path.Peek();
if (Vector3.Distance(tilemap.WorldToCell(transform.position), target) >= 0.005f)
{
transform.position = Vector3.MoveTowards(transform.position, tilemap.CellToWorld(target), 1f * Time.deltaTime);
}
else
{
transform.position = tilemap.CellToWorld(target);
Debug.Log(path.Count);
Debug.Log(path.Peek());
path.Pop();
}
}
else
{
Debug.Log("Path Empty");
}
}
All the debugging spits out the expected data such as path count, target location, transform location, etc… and I check this every tile moved and it always correct in pointing at the next tile. But for some reason unknown to me, the player moves properly along the x axis (slides slowly from tile to tile) then along y axis almost teleports super fast from tile to tile. If anyone has run into this before or has any ideas I would love to hear from you. Cheers