Hi i’m working on a A* pathfind and i need a visual rappresentation of path / collision.
Atm i build something that working great, the main problem it is performance when i use a “big” grid (900x900).
I use my app only in unit editor cause it is only to test A*.
If i display only Pathfind result no problem but i i wanna display also “collision object” i have problem (cause it will draw all cubes)
I use this code to display collision objec alias a red cube:
My question there is a optimization that i can see all pathfind (magenta) and collision (cubes) without performance issue?
public List<Node> unwalkable; //cluster not walkable
public List<Node> path; //Pathfind result
Node[,] grid; //Grid 900x900
void OnDrawGizmos()
{
Gizmos.DrawWireCube(transform.position, new Vector3(gridWorldSize.x, 1, gridWorldSize.y));
if (path != null)
{
foreach (Node n in path)
{
Gizmos.color = Color.magenta;
Gizmos.DrawCube(n.worldPosition, Vector3.one * (nodeDiameter - .1f));
}
}
if (!onlyDisplayPathGizmos)
{
if (grid != null)
{
if (unwalkable == null)
{
unwalkable = new List<Node>();
foreach (Node n in grid)
{
if (!n.walkable)
{
unwalkable.Add(n);
}
}
}
foreach (Node n in unwalkable)
{
Gizmos.color = Color.red;
Gizmos.DrawCube(n.worldPosition, Vector3.one * (nodeDiameter - .1f));
}
}
}
}