Ejemplo n.º 1
0
    IEnumerator Move_Routine()
    {
        float curveDuration    = motionCurve.GetLength();
        float offset           = Random.Range(offsetCanBeNegative ? -randomDurationOffset : 0.0f, randomDurationOffset);
        float movementDuration = duration + offset;

        float t = 0;

        while (t < 1.0f)
        {
            factor = motionCurve.Evaluate(t * curveDuration);
            rect.anchoredPosition = startPosition + (Vector2.up * factor * movementAmplitude);

            t += Time.deltaTime / movementDuration;
            yield return(new WaitForEndOfFrame());
        }

        float interval = baseInterval + Random.Range(0.0f, randomIntervalAdd);

        if (intervalUsesDuration)
        {
            interval *= duration;
        }

        yield return(new WaitForSeconds(interval));

        moveCorout = StartCoroutine(Move_Routine());
    }