Example #1
0
    public override void AIbehavior()
    {
        if (!isScreamed)
        {
            Screaming();
        }
        else
        {
            animator.SetBool("Scream", false);

            if (zombieAI.target == null)
            {
                zombieAI.SetZombieState(zombieAI.partolState);
                return;
            }
            if (!zombieAI.navMeshAgent.isOnNavMesh || zombieAI.patrolSettings.waypoints.Length == 0)
            {
                return;
            }
            zombieAI.navMeshAgent.SetDestination(zombieAI.target.position);

            zombieAI.LookAtPosition(zombieAI.navMeshAgent.steeringTarget);

            zombieAI.zombieAudio.PlayZombieWalkSound();
            //走到玩家面前了
            if (zombieAI.navMeshAgent.remainingDistance <= zombieAI.attackSettings.attackRange - 1)
            {
                zombieAI.walkingToDest = false;
                zombieAI.forward       = 0;
                Attacking();
            }
            else
            {
                zombieAI.walkingToDest = true;
                zombieAI.forward       = zombieAI.LerpSpeed(zombieAI.forward, 1f, 15);
                animator.SetBool("Attack", false);
            }
            zombieMove.JustAnimate(zombieAI.forward, 0);
        }
    }