// Update is called once per frame void Update() { switch (_state) { case PATROL_ROBOT_STATE.PATROL: //パトロール if (!_agent.pathPending && _agent.remainingDistance < 0.5f) { Invoke("GoToNextPoint", 1f); i++; if (i == _patrol.Length) { i = 0; } } break; case PATROL_ROBOT_STATE.CHASE: //追う _agent.SetDestination(_tarPos.transform.position); break; case PATROL_ROBOT_STATE.RETURN: //戻る _agent.SetDestination(_prePos.transform.position); if (transform.localPosition.x == _prePos.transform.localPosition.x) { i = 0; _state = PATROL_ROBOT_STATE.PATROL; } break; } }
// Use this for initialization void Start() { _agent = GetComponent <NavMeshAgent> (); _state = PATROL_ROBOT_STATE.PATROL; }