public void UpdateAction() { if (!CheckAvailability()) { return; } ParentCharacter.SendCommand(CharacterCommands.Aim); CsDebug.Inst.CharLog(ParentCharacter, "is search dest set? " + _isSearchDestSet); if (_isSearchDestSet) { if (Vector3.Distance(ParentCharacter.transform.position, _searchDest) > 1) { ParentCharacter.Destination = _searchDest; ParentCharacter.SendCommand(CharacterCommands.GoToPosition); CsDebug.Inst.CharLog(ParentCharacter, "Sent command to go to " + ParentCharacter.Destination); if (ParentCharacter.GetCharacterVelocity().magnitude <= 0) { _isSearchDestSet = false; } } else { _isSearchDestSet = false; ParentCharacter.MyAI.BlackBoard.IsNavTargetSet = false; } } else { //search random locations Vector3 searchCenter = ParentCharacter.transform.position; Vector3 searchRange = new Vector3(5, 5, 5); if (ParentCharacter.MyAI.BlackBoard.InvisibleEnemy != null) { if (_searchTimer < 10) { searchCenter = ParentCharacter.MyAI.BlackBoard.InvisibleEnemy.transform.position; searchRange += new Vector3(_searchTimer / 2, 0, _searchTimer / 2); } else { searchCenter = ParentCharacter.MyAI.BlackBoard.PatrolLoc; searchRange = ParentCharacter.MyAI.BlackBoard.PatrolRange; } } ParentCharacter.MyAI.BlackBoard.IsNavTargetSet = SelectSearchDestination(searchCenter, new Vector3(5, 5, 5), out _searchDest); _isSearchDestSet = ParentCharacter.MyAI.BlackBoard.IsNavTargetSet; if (ParentCharacter.MyAI.BlackBoard.IsNavTargetSet) { ParentCharacter.MyAI.BlackBoard.NavTarget = _searchDest; ParentCharacter.Destination = ParentCharacter.MyAI.BlackBoard.NavTarget; ((HumanCharacter)ParentCharacter).CurrentStance = HumanStances.Walk; ParentCharacter.SendCommand(CharacterCommands.GoToPosition); //CsDebug.Inst.CharLog(ParentCharacter, "Sent command to go to " + ParentCharacter.Destination); ParentCharacter.MyAI.TargetingSystem.SetTargetingMode(AITargetingModes.LookAheadAround, Vector3.zero); } } if (_searchTimer >= _nextTalkTime) { ParentCharacter.PlayVocal(VocalType.Search); _nextTalkTime = _searchTimer + UnityEngine.Random.Range(5, 10); } _searchTimer++; //check if patrol is complete if (CheckActionCompletion()) { StopAction(); ParentCharacter.MyEventHandler.TriggerOnActionCompletion(); } }