mirror of
				https://github.com/DerTyp7/fps-citybuild-unity.git
				synced 2025-10-31 05:07:08 +01:00 
			
		
		
		
	Pathfinding rework
Pulled the whole thing apart and glued it back together
This commit is contained in:
		| @@ -8,32 +8,31 @@ public class NPCController : MonoBehaviour | ||||
|     PathMap Map; | ||||
|     private GameObject[,] ball; | ||||
|     public List<PathNode> path; | ||||
|     private int rows; | ||||
|     [SerializeField] Vector3 startPoint; | ||||
|     [SerializeField] Vector3 endPoint; | ||||
|  | ||||
|     // Start is called before the first frame update | ||||
|     void Start() | ||||
|     { | ||||
|         ball = new GameObject[30, 30]; | ||||
|         Map = new PathMap(new Vector3(0, 0, 0), 30, 30, 30); | ||||
|         for (int r = 0; r < 30; r++) | ||||
|         { | ||||
|             for (int c = 0; c < 30; c++) | ||||
|             { | ||||
|         startPoint = new Vector3(0,0,0); | ||||
|         endPoint = new Vector3(100,0,100); | ||||
|         rows = 45; | ||||
|         Map = new PathMap(new Vector3(0, 0, 0), rows, rows, 100); | ||||
|         Debug.Log("yeet"); | ||||
|         Map.setupMapWithNextLayer(); | ||||
|         //Looking through the low res search | ||||
|         //path = Map.QueryNodes(startPoint,endPoint); | ||||
|         if (path != null) { | ||||
|             for (int i = 0; i < path.Count - 1; i++) { | ||||
|                 int x = path[i].index.x; | ||||
|                 int y = path[i].index.y; | ||||
|                 Debug.Log(path[i].index); | ||||
|                 Debug.Log(path[i].Position); | ||||
|                 GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Cube); | ||||
|                 sphere.transform.position = Map.map[r, c].Position; | ||||
|                 ball[r, c] = sphere; | ||||
|  | ||||
|  | ||||
|                 sphere.transform.position = Map.map[x, y].Position; | ||||
|             } | ||||
|         } | ||||
|         path = Map.QueryNodes(new Vector3(0,0, 0), new Vector3(100, 0,100)); | ||||
|         //Debug.Log("yeet"); | ||||
|         Debug.Log(path.Count); | ||||
|         Debug.Log((int)path[0].index.x + " "+ (int)path[0].index.y); | ||||
|         for (int i = 0; i < path.Count - 1; i++) { | ||||
|             int x = path[i].index.x; | ||||
|             int y = path[i].index.y; | ||||
|             Destroy(ball[x, y]); | ||||
|         } | ||||
|          | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 juliuse98
					juliuse98