private void MoveTowardsOrigin() { if (pathfinding.HasPath()) { //If we have no path then request one //First, if we are too close (and can see the target) then we need to create some distance! if (GetDistanceToOrigin() < 4 && CheckLineOfSight(eyes.position, pointOfOrigin)) { run = GetDirectionToOrigin().x < 0 ? -1 : 1; return; } if (IsPathToOriginStillValid()) { if (FollowPath()) { if (verboseDebug) { Debug.Log(name + ": " + enemyState + ": I reached the end of my path so requested a new one"); } } } else { if (verboseDebug) { Debug.Log(name + ": " + enemyState + ": my path was no longer valid so I requested a new one"); } pathfinding.SetPathUnvalid(); } } else { //We have a path //First, if we are too close then we need to create some distance! if (!pathfinding.hasRequestedPath) { pathfinding.RequestPath(pointOfOrigin); //Debug.Log("Requested Path"); } if (pointOfOrigin.x > transform.position.x) { run = 1; } else { run = -1; } } }