Exemplo n.º 1
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    void Update()
    {
        GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
        distance = Vector3.Distance(Player.transform.position, transform.position);
        if (!Attacking && !dead)
        {
            if (distance < LineOfSight)
            {
                if (distance < (LineOfSight / 2) || Sight.Sighted())
                {
                    engaged        = true;
                    EngagementTime = minimumEngagementTime + Time.time;
                }
            }
            else
            {
                engaged = false;
            }

            if (engaged || EngagementTime > Time.time)
            {
                StateUpdate();
            }
            else
            {
                if (ResetNeeded)
                {
                    Reset();
                }
                GetComponent <Patrol>().Patrolling();
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Update is called once per frame.
    /// </summary>
    void Update()
    {
        GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
        distance = Vector3.Distance(Player.transform.position, transform.position);
        if (!Attacking && !dead)
        {
            if (distance < LineOfSight)
            {
                if (distance < (LineOfSight / 2) || Sight.Sighted())
                {
                    engaged        = true;
                    EngagementTime = minimumEngagementTime + Time.time;
                }
            }
            else
            {
                engaged = false;
            }

            if (engaged || EngagementTime > Time.time)
            {
                StateUpdate();
            }
            else
            {
                if (ResetNeeded)
                {
                    Reset();
                }
                GetComponent <Patrol>().Patrolling();
            }
        }

        stateInfo = anim.GetCurrentAnimatorStateInfo(0);

        if (!isActivatingAttack && stateInfo.IsName("Attack"))
        {
            StopCoroutine(ActivatingAttack());
            StartCoroutine(ActivatingAttack());
        }
    }