Ejemplo n.º 1
0
    void Patrol()
    {
        // tell nav agent that he can move
        navmesh_Agent.isStopped = false;
        navmesh_Agent.speed     = walk_Speed;

        // add to the patrol timer
        patrol_Timer += Time.deltaTime;

        if (patrol_Timer > patrol_For_This_Time)
        {
            SetNewRandomDestination();

            patrol_Timer = 0f;
        }

        if (navmesh_Agent.velocity.sqrMagnitude > 0)
        {
            enermy_Animator.Walk(true);
        }
        else
        {
            enermy_Animator.Walk(false);
        }

        // test the distance between the player and the enemy
        if (Vector3.Distance(transform.position, target.position) <= chase_Distance)
        {
            enermy_Animator.Walk(false);

            Enermy_State = EnermyState.CHASE;

            // play spotted audio
            enermyAudio.Play_ScreamSound();
        }
    } // patrol