protected void Patrol(AI_BehaviorBrain brain) { NavMeshAgent agent = brain.navMeshAgent; AI_PatrolData patrolData = brain.GetComponent <AI_PatrolData>(); ptrSplineLine = patrolData.ptrSplineLine; if (agent != null && ptrSplineLine != null) { currentPreviousSplinePoint = patrolData.currentPreviousSplinePoint; agent.destination = ptrSplineLine.transform.TransformPoint(ptrSplineLine.GetNextControlPoint(currentPreviousSplinePoint)); agent.isStopped = false; agent.stoppingDistance = stopDist; if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending) { //int pointCnt = ptrSplineLine.GetControlPointCount; //int nextPointIndex = ptrSplineLine.GetNextControlPointIndex(currentPreviousSplinePoint); ArrivedAtDestination(brain); } } }