mirror of
				https://github.com/DerTyp7/fps-citybuild-unity.git
				synced 2025-10-31 13:17:07 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| 
 | |
| public class NPCController : MonoBehaviour
 | |
| {
 | |
| 
 | |
|     PathMap Map;
 | |
|     private GameObject[,] ball;
 | |
|     public List<PathNode> path;
 | |
|     private int rows;
 | |
|     [SerializeField] Vector3 startPoint;
 | |
|     [SerializeField] Vector3 endPoint;
 | |
|     bool first = false;
 | |
|     bool second = false;
 | |
| 
 | |
|     // Start is called before the first frame update
 | |
|     void Start()
 | |
|     {
 | |
|         startPoint = new Vector3(0, 0, 0);
 | |
|         endPoint = new Vector3(200, 0, 900);
 | |
|         rows = 30;
 | |
|         Map = new PathMap(new Vector3(0, 0, 0), rows, rows, 900);
 | |
|         Map.setupMapWithNextLayer();
 | |
| 
 | |
|         List<PathNode> parentPath;
 | |
|         //Looking through the low res search
 | |
|         
 | |
|     }
 | |
| 
 | |
| 
 | |
|     // Update is called once per frame
 | |
|     void Update()
 | |
|     {
 | |
|         if (Input.GetButtonDown("Fire1") && !first)
 | |
|         {
 | |
|             first = true;
 | |
|             Debug.Log(Time.time * 1000);
 | |
|             path = Map.LowerQueryNodes(startPoint, endPoint);
 | |
|             
 | |
| 
 | |
|         }
 | |
|         else if(!second && first){
 | |
|             second = true;
 | |
|             Debug.Log(Time.time * 1000);
 | |
|             if (path != null && true)
 | |
|             {
 | |
|                 for (int i = 0; i < path.Count - 1; i++)
 | |
|                 {
 | |
|                     float x = path[i].Position.x;
 | |
|                     float y = path[i].Position.y;
 | |
| 
 | |
|                     //Debug.Log(path[i].index);
 | |
|                     //Debug.Log(path[i].Position);
 | |
| 
 | |
|                     GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Cube);
 | |
|                     sphere.transform.position = path[i].Position;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | 
