public IEnumerator UpdatePath() { if (Time.timeSinceLevelLoad < 0.3f) { Debug.Log("Waiting for level load"); yield return(new WaitForSeconds(0.3f)); } PathRequestController.RequestPath((Vector2)transform.position, (Vector2)player.transform.position, OnPathFound); float sqrMoveThreshold = pathUpdateMoveThreshold * pathUpdateMoveThreshold; while (true) { Vector3 targetPosOld = player.transform.position; yield return(new WaitForSeconds(minPathUpdateTime)); // if ((player.transform.position - targetPosOld).sqrMagnitude > sqrMoveThreshold) { PathRequestController.RequestPath((Vector2)transform.position, (Vector2)player.transform.position, OnPathFound); targetPosOld = player.transform.position; // } if (distance < 2) { // Debug.Log("chasing"); currentWaypoint = player.transform.position; } } }
void Start() { requestManager = GetComponent <PathRequestController>(); var mapObject = GameObject.Find("MapGridObject"); tilemap = mapObject.transform.GetChild(0).gameObject.GetComponent <Tilemap>(); mapGenerator = mapObject.GetComponent <MapGenerator>(); map = mapObject.GetComponent <Map>(); tileTools = GameObject.Find("TileTools").GetComponent <TileTools>(); }
public IEnumerator PathToLocation(Vector2 location) { if (Time.timeSinceLevelLoad < 0.3f) { Debug.Log("Waiting for level load"); yield return(new WaitForSeconds(0.3f)); } PathRequestController.RequestPath((Vector2)transform.position, location, OnPathFound); }
void Awake() { instance = this; a = GetComponent<A_Pathfinding>(); }
void Awake() { instance = this; pathfinding = GetComponent <Pathfinding>(); }
void FindPath() { PathRequestController.RequestPath(transform.position, player.position, OnPathFound); }
void Awake() { request = GetComponent <PathRequestController>(); grid = GetComponent <Grid>(); }
void Awake() { request = GetComponent<PathRequestController>(); grid = GetComponent<Grid>(); }
//Moves the unit from one point to another public void MoveUnit(Vector3 from, Vector3 to) { PathRequestController.RequestPath(from, to, OnPathFound); TargetReached = false; }
void Awake() { instance = this; a = GetComponent <A_Pathfinding>(); }