示例#1
0
    private void Update()
    {
        FaceTarget();
        float distToPlayer = Vector3.Distance(transform.position, playerTransform.position);

        if (distToPlayer < distToShield + 1 && distToPlayer > distToPlayer - 1)
        {
            attacking = true;
            if (activatePathing)
            {
                activatePathing = false;
                pathFinder.StopPathing();
            }
            if (right)
            {
                body.velocity = directionFinder.GetRightDirection().normalized *walkShieldingSpeed *Time.fixedDeltaTime;
            }
            else
            {
                body.velocity = directionFinder.GetLeftDirection().normalized *walkShieldingSpeed *Time.fixedDeltaTime;
            }
        }
        else
        {
            attacking = false;
            if (!activatePathing)
            {
                activatePathing = true;;
                pathFinder.StartNewPath();
            }
        }
        Shield();
    }
    IEnumerator DashDelay()
    {
        yield return(new WaitForSeconds(dashDelay));

        pathFinder.StartNewPath();
        attacking = false;
    }