public Vector3 GetDestinationOnPath() { if (IsPathValid()) { return(PatrolPath.GetPositionOfPathNode(m_PathDestinationNodeIndex)); } else { return(transform.position); } }
public void SetPathDestinationToClosestNode() { if (IsPathValid()) { int closestPathNodeIndex = 0; for (int i = 0; i < PatrolPath.PathNodes.Count; i++) { float distanceToPathNode = PatrolPath.GetDistanceToNode(transform.position, i); if (distanceToPathNode < PatrolPath.GetDistanceToNode(transform.position, closestPathNodeIndex)) { closestPathNodeIndex = i; } } m_PathDestinationNodeIndex = closestPathNodeIndex; } else { m_PathDestinationNodeIndex = 0; } }