Example #1
0
    public IEnumerator DodgeBack(Vector3 fromPosition)
    {
        int checks = 0;

        if (dodge == false)
        {
            yield break;
        }

        transform.LookAt(fromPosition);
        canMove = false;

        CompleteDest = true;
        Vector3 pos = GetPositionFromLocal(Vector3.back, dodgeBackDist);

        navAgent.SetDestination(pos);
        unitAnimator.DodgeBack();
        while (true)
        {
            checks++;
            navAgent.SetDestination(pos);

            if (CheckDist() <= navmeshDestinationReachDist | checks >= 20)
            {
                yield return(new WaitForSeconds(0.1f));

                angularSpeed = StartAngularSpeed;
                maxSpeed     = startSpeed;
                Acceleration = startAcceleration;
                canMove      = true;
                yield break;
            }


            angularSpeed = 0f;
            maxSpeed     = StrafePower;
            Acceleration = StrafePower * 20;



            yield return(new WaitForSeconds(0.1f));
        }
    }