From cd15c103c6f1113461ead6065e47130276cb61a1 Mon Sep 17 00:00:00 2001 From: Simon O'Shea Date: Wed, 9 Aug 2023 09:37:44 -0400 Subject: astar is animated primitively --- Pathfinding Visualizer/Assets/Scripts/Main.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Pathfinding Visualizer/Assets/Scripts/Main.cs') diff --git a/Pathfinding Visualizer/Assets/Scripts/Main.cs b/Pathfinding Visualizer/Assets/Scripts/Main.cs index 8cbb5ce..590723b 100644 --- a/Pathfinding Visualizer/Assets/Scripts/Main.cs +++ b/Pathfinding Visualizer/Assets/Scripts/Main.cs @@ -102,14 +102,16 @@ public class Main : MonoBehaviour public void ResetGrid() { world.reset(); - agent = new Vector2Int(-1, -1); + agent = new Vector2Int(); obstacles = new List(); samples = new List(); } public void StartAlgorithm() { + Vector2Int coord = new Vector2Int(); + bool agentFound = false; // Collect information about world for (int x = 0; x < world.GetWidth(); x++) @@ -138,15 +140,16 @@ public class Main : MonoBehaviour if (!samples.Contains(coord)) samples.Add(coord); } - // Add coordinate to obstacle array + // Add coordinate to agent array if (value == 3) { agent.x = x; agent.y = y; + agentFound = true; } } - if (agent.x == -1 && agent.y == -1) + if (!agentFound) { Debug.Log("NO AGENT!"); return; @@ -157,11 +160,12 @@ public class Main : MonoBehaviour Debug.Log("NO SAMPLES!"); return; } - if ( true ) { Pathfinder path = new Pathfinder(world, agent, obstacles, samples, 0, 0); + Stack result = path.result; + cellMesh.Animate(result); } } -- cgit v1.3.1-4-g156e