예제 #1
0
    // 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);
        }
    }
예제 #2
0
    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();
        }
    }
    public void EnterSnippet()
    {
        //Debug.Log(_agent.transform.name + " Advance Snippet");

        //Sets the player as our target
        _aiWeapon.SetTarget(_agent.Player);

        //Navigate to a point near the last known location
        _navAgent.SetDestination(_lastKnownLocation.GeneratePointInRangeWithRaycast(12.5f));

        //Set the stopping distance low
        _navAgent.stoppingDistance = 0.5f;
    }