示例#1
0
    private IEnumerator WaitForNotTakingStep(LegIndex legIndex)
    {
        int legIndexValue = (int)legIndex;

        while (takingStep[legIndexValue])
        {
            yield return(null);
        }
    }
示例#2
0
    private IEnumerator TakeStepInPlace(LegIndex legIndex)
    {
        int legIndexValue = (int)legIndex;

        takingStep[legIndexValue] = true;
        if (LegIndex.FrontLeft == legIndex || LegIndex.FrontRight == legIndex)
        {
            SetTargets(legIndexValue, frontStepUp);
            yield return(new WaitForSeconds(delay * 5));

            SetTargets(legIndexValue, defaultStep);
        }
        else
        {
            SetTargets(legIndexValue, backStepUp);
            yield return(new WaitForSeconds(delay * 5));

            SetTargets(legIndexValue, defaultStep);
        }
        takingStep[legIndexValue] = false;
    }
示例#3
0
    private IEnumerator TakeStep(LegIndex legIndex, bool backwards)
    {
        int legIndexValue = (int)legIndex;

        takingStep[legIndexValue] = true;
        if (LegIndex.FrontLeft == legIndex || LegIndex.FrontRight == legIndex)
        {
            SetTargets(legIndexValue, frontStepForward, backwards);
            yield return(new WaitForSeconds(delay));

            SetTargets(legIndexValue, frontStepExtended, backwards);

            Leg     leg   = legs[legIndexValue];
            Vector3 point = body.transform.InverseTransformPoint(leg.ankle.transform.position);
            while (point.y < 3f && !backwards)
            {
                if (walkingInPlace)
                {
                    yield break;
                }
                yield return(null);

                point = body.transform.InverseTransformPoint(leg.ankle.transform.position);
            }
            while (point.y > 0 && backwards)
            {
                if (walkingInPlace)
                {
                    yield break;
                }
                yield return(null);

                point = body.transform.InverseTransformPoint(leg.ankle.transform.position);
            }

            SetTargets(legIndexValue, frontStepGrounded, backwards);
        }
        else
        {
            SetTargets(legIndexValue, backStepRetracted, backwards);
            yield return(new WaitForSeconds(delay * 2f));

            SetTargets(legIndexValue, backStepForward, backwards);
            yield return(new WaitForSeconds(delay));

            SetTargets(legIndexValue, backStepExtended, backwards);

            Leg     leg   = legs[legIndexValue];
            Vector3 point = body.transform.InverseTransformPoint(leg.ankle.transform.position);
            while (point.y < 0.6f && !backwards)
            {
                if (walkingInPlace)
                {
                    yield break;
                }
                yield return(null);

                point = body.transform.InverseTransformPoint(leg.ankle.transform.position);
            }
            while (point.y > -1.5f && backwards)
            {
                if (walkingInPlace)
                {
                    yield break;
                }
                yield return(null);

                point = body.transform.InverseTransformPoint(leg.ankle.transform.position);
            }

            SetTargets(legIndexValue, backStepGrounded, backwards);
            yield return(new WaitForSeconds(delay));

            SetTargets(legIndexValue, backStepGroundedStraight, backwards);
        }
        takingStep[legIndexValue] = false;
    }