// 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 void TakeCover() { //Crouch down _anim.SetBool("isCrouching", true); //Clear the target and stop the ai from shooting _aiWeapon.SetTarget(null); _aiWeapon.SetFiring(false); //Increase cover timer _changeCoverTimer += Time.deltaTime; //See if we need to Change covers if (_changeCoverTimer > _changeCoverDuration) { SelectCover(); } }
private void DecideToReload() { //Check if we need to reload if (_aiWeapon.GetEquippedWeapon().NeedToReload) { //Stop firing _aiWeapon.SetFiring(false); //If we are not reloading, then reload the current gun if (!_aiWeapon.GetEquippedWeapon().IsReloading) { //Debug.Log("Reloading"); _aiWeapon.GetEquippedWeapon().Reload(); } //If the AI does not have any bullets left, then switch to the melee state if (_aiWeapon.GetEquippedWeapon().TotalAmmo <= 0) { _agent.stateMachine.ChangeState(AiStateId.Melee); } } }
public void EnterSnippet() { //Debug.Log(_agent.transform.name + " Reload Snippet"); _aiWeapon.SetFiring(false); }