Пример #1
0
    // Update is called once per frame
    void Update()
    {
        //updating animation variables not including triggers
        animator.SetBool("IsGrounded", IsGrounded());
        animator.SetFloat("VelocityY", rb.velocity.y);

        //end of animaton variables
        if (IsGrounded() && !isAttacking && (Mathf.Abs(player.position.x - this.transform.position.x)) < aggroDistance && hp.getHP() > 0)
        {
            StartCoroutine(Attack());
            isAttacking = true;
        }
        if (hp.getHit() == true && hp.getHP() > 0)
        {
            animator.SetTrigger("Hit");
            hp.hitReceived();
        }
        if (hp.getHP() <= 0)
        {
            animator.SetBool("Death", true);
            //freeze position and dont interact with collisions
            if (IsGrounded())
            {
                rb.constraints = RigidbodyConstraints2D.FreezeAll;
                col.enabled    = false;
            }

            //GameObject.Destroy(this.gameObject);
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastAttack += Time.deltaTime;
        CalculateDistance();
        //Animations here

        if (hp.getHP() > 0)
        {
            PointTowardsPlayer();
            if (playerDistance < aggroDistance && notHit && playerDistance > attackRange)
            {
                FollowPlayer();
            }
            else if (notHit)
            {
                moveX = 0;
            }

            if (playerDistance < attackRange && attackSpeed <= timeSinceLastAttack)
            {
                Shoot();
            }
        }
        if (hp.getHit() == true)
        {
            Hit();
            hp.hitReceived();
        }
        if (hp.getHP() <= 0)
        {
            moveX = 0;
            ani.SetBool("Death", true);
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastAttack += Time.deltaTime;
        CalculateDistance();
        Animations();
        if (playerDistance < agroDistance && notHit && hp.getHP() > 0 && playerDistance > dontMoveDistance)
        {
            FollowPlayer();
        }
        else if (notHit)
        {
            moveX = 0;
        }

        if (playerDistance < attackDistance && attackSpeed <= timeSinceLastAttack && hp.getHP() > 0)
        {
            Stab();
        }
        if (hp.getHit() == true)
        {
            Hit();
            hp.hitReceived();
        }
    }