Ejemplo n.º 1
0
    void LateUpdate()
    {
        // Choose the next destination point when the agent gets
        // close to the current one.

        if (aracaMiCarpti)
        {
            return;
        }

        float distance = Vector3.Distance(player.transform.position, transform.position);

        if (distance <= 2f && !code.GetComponent <gameControl> ().carDrivingMode&& !code.GetComponent <gameControl> ().oturmaMode)
        {
            //2 metre yakınında ajanı durdurup bize baktır
            agent.isStopped = true;
            //purr
            agent.GetComponents <AudioSource> () [1].enabled = true;
            agent.GetComponents <AudioSource> () [0].enabled = false;
            if (!birKereSesCalis)
            {
                birKereSesCalis = true;
                agent.GetComponent <Animator> ().SetBool("durArtik", true);
            }

            RotateTowards(player.transform);
        }
        else
        {
            agent.isStopped = false;
            birKereSesCalis = false;
            //mioo
            agent.GetComponents <AudioSource> () [0].enabled = true;
            agent.GetComponents <AudioSource> () [1].enabled = false;
            agent.GetComponent <Animator> ().SetBool("durArtik", false);
            if (!agent.pathPending && agent.remainingDistance < 0.5f)
            {
                GotoNextPoint();
            }
        }
    }