private void SetStates(AI_BehaviorBrain brain, AI_BehaviorBrain[] brainList, AI_State state) { foreach (AI_BehaviorBrain currbrain in brainList) { //Debug.Log(currbrain.gameObject.name+" from:"+ currbrain.currentState.ToString()+" to:"+state.ToString()); AI_State currBrainState = currbrain.currentState; if (currBrainState != state) { bool replace = true; foreach (AI_State curState in noReplacedState) { if (currBrainState == curState) { replace = false; break; } } if (replace) { currbrain.ChangeState(state); //currbrain.currentState = state; } } AI_GoToData goToData = currbrain.GetComponent <AI_GoToData>(); if (goToData != null) { if (goToData.destination != brain.transform.position) { goToData.destination = brain.transform.position; } goToData.stopDist = stopDist; } } }
private void GoTo(AI_BehaviorBrain brain) { NavMeshAgent agent = brain.navMeshAgent; AI_GoToData goToData = brain.GetComponent <AI_GoToData>(); if (agent != null && goToData.destination != null) { agent.destination = goToData.destination; agent.stoppingDistance = goToData.stopDist; //if(Vector3.Distance(brain.transform.position, agent.destination)<= agent.stoppingDistance) //{ // agent.isStopped = true; //} //else //{ // agent.isStopped = false; //} } }