public void Death()
 {
     animator.SetTrigger("death");
     animator.SetInteger(EnemyAIManager.Instance().transitionParameter, (int)Transition.DEATH);
     enabled = false;
     solidPhysicalCollider.enabled = false;
 }
示例#2
0
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (ChaseState.ShouldChasePlayer(animator.transform.position))
     {
         animator.SetInteger(EnemyAIManager.Instance().transitionParameter, (int)Transition.CHASE);
     }
     else if (!navAgent.hasPath)
     {
         animator.SetInteger(EnemyAIManager.Instance().transitionParameter, (int)Transition.IDLE);
     }
 }
示例#3
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateMove is called right after Animator.OnAnimatorMove()
    override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!ShouldChasePlayer(animator.transform.position))
        {
            animator.SetInteger(EnemyAIManager.Instance().transitionParameter, (int)Transition.IDLE);
        }
        else
        {
            if (!navAgent.hasPath || (player.transform.position - navAgent.pathEndPosition).sqrMagnitude > repathTolerance * repathTolerance)
            {
                SetDestinationNearTarget(navAgent, player);
            }
        }
    }
示例#4
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (navAgent == null)
        {
            navAgent = animator.GetComponentInParent <NavMeshAgent>();
        }

        if (player == null)
        {
            player = EnemyAIManager.Instance().player;
        }

        // Reset the path so the AI could create new path to chase the player
        navAgent.ResetPath();
        navAgent.speed = runSpeed;
    }
示例#5
0
    public static bool ShouldChasePlayer(Vector3 chaserPosition)
    {
        ThirdPersonControl p = EnemyAIManager.Instance().player;

        return((p.transform.position - chaserPosition).sqrMagnitude < chaseRadius * chaseRadius);
    }