// Update is called once per frame void Update() { if (_beingKilled) { return; } //If we are dead if (_aiHealth.IsDead) { //Change to death state, activates ragdoll and drops weapons stateMachine.ChangeState(AiStateId.Death); _player.GetComponent <PlayerController>().AgentInRange = null; //Destroy the assassination target component and this ai agent component Destroy(GetComponentInChildren <AssassinationTarget>()); Destroy(this); } stateMachine.Update(); _currentState = stateMachine._currentState; if (_player.GetComponent <PlayerHealth>().IsDead) { //Dances, and then stops the AIn from firing and clears the target GetComponent <Animator>().SetBool("PlayerDead", true); GetComponent <NavMeshAgent>().SetDestination(transform.position); _aiWeapon?.SetFiring(false); _aiWeapon?.SetTarget(null); } }
private IEnumerator AICycle() { while (enabled) { stateMachine?.Update(); // stateMachine?.SetStateTargetVector(AIBlackboard.Instance.player.transform.position); MoveAI(); if (!targetTransform && !isEngaging) { isSprinting = false; //Stop Sprinting Animation } else if (Vector3.SqrMagnitude(mTransform.position - stateMachine.TargetVector) < agentStats.distanceFromTargetToSprint && isEngaging) { //Stop Sprinting Animation AdjustSpeed(); } yield return(new WaitForSeconds(AIController.Instance.agentCycleTime)); } }
void Update() { stateMachine.Update(); }
// Update is called once per frame void Update() { machine.Update(); }