Im almost done in implementing pathfinding using A*, the problem is that anything beyond the yellow axis in the tilemap (negative y coordinates) does not register in the astar points. I checked why and I discovered that the MapSize (which I set to 32,32) only registers tiles from 0-32 both on x and y.
Method that registers all the tiles in the Astar node
List<Vector2> pointPath = new List<Vector2>();
foreach(var y in GD.Range((int)MapSize.y))
{
foreach(var x in GD.Range((int)MapSize.x))
{
var point = new Vector2(x, y);
if (ExistsInArray(point, Obstacles)) continue;
int pointIndex = CalculatePointIndex(point);
pointPath.Add(point);
AstarNode.AddPoint(pointIndex, new Vector3(point.x, point.y, 0.0f));
}
}
return pointPath;
Method that calculates the ID
return (int)(point.x + MapSize.x * point.y);
This code is not mine, it's from GDQuest, I just translated it to C#. I tried moving the tilemap node, and it did not work. I tried moving the camera and it still did not work. I noticed that no matter where the camera is, the top left corner is always 0,0. Hence, I couldnt place tiles beyond Y = -1.