public IEnumerator GetPathTest(Vector3 entry, Vector3 exit) { // NavPath = null; int task = ThreadedNavigator.GetPath(entry, exit); float time = Time.realtimeSinceStartup; while (!ThreadRunner.isComplete(task)) { Debug.Log("Waiting for nav thread to complete..."); yield return(null); } List <Vector3> myPath = (List <Vector3>)ThreadRunner.FetchData(task); // NavPath = myPath; if (myPath == null) { Debug.Log("No path found."); } else { Debug.Log("Path length: " + myPath.Count); for (int i = 0; i < myPath.Count - 1; i++) { Debug.DrawLine(myPath[i], myPath[i + 1], Color.magenta, 5f); } } Debug.Log("Took " + (Time.realtimeSinceStartup - time) + "s to generate."); }
public void ClickAction(Vector3 WorldPos) { Vector3 localpos = WorldPos - transform.position; byte b = SiegeTerrain.GetTile(WorldPos.x / TileWidth, WorldPos.z / TileWidth); if (b > 0) { b = 0; } else { b = 1; } SiegeTerrain.UpdateTile(WorldPos.x / TileWidth, WorldPos.z / TileWidth, b); UpdateMesh(); // TODO: Call navmesh patch function for this tile. ThreadedNavigator.GenerateNavMesh(); }
IEnumerator GetPath(Vector3 entry, Vector3 exit) { NavPath = null; int task = ThreadedNavigator.GetPath(entry, exit); while (!ThreadRunner.isComplete(task)) { // Debug.Log("Waiting for nav thread to complete..."); yield return(null); } List <Vector3> myPath = (List <Vector3>)ThreadRunner.FetchData(task); NavPath = myPath; if (myPath == null) { Debug.Log("No path found."); } else { Debug.Log("Path length: " + myPath.Count); } }
void Awake() { main = this; }