Bounce() публичный статический Метод

public static Bounce ( float x ) : float
x float
Результат float
Пример #1
0
        private float AnimationCurveCompletionPerc(float origPercentage)
        {
            switch (AnimationCurve)
            {
            case AnimationCurves.Linear:
            {
                return(Mathfx.Lerp(0, 1, origPercentage));
            }

            case AnimationCurves.Elastic:
            {
                return(Mathfx.Berp(0, 1, origPercentage));
            }

            case AnimationCurves.Bounce:
            {
                return(Mathfx.Bounce(origPercentage));
            }

            case AnimationCurves.EaseInOut:
            default:
            {
                return(Mathfx.Hermite(0, 1, origPercentage));
            }
            }
        }
Пример #2
0
    /// <summary>
    /// Return value based on curve from Mathfx class.
    /// </summary>
    /// <returns>The value.</returns>
    /// <param name="animationCurve">Animation curve.</param>
    /// <param name="start">Start.</param>
    /// <param name="end">End.</param>
    /// <param name="t">T.</param>
    public static float CurvedValue(AnimationCurveEnum animationCurve, float start, float end, float t)
    {
        switch (animationCurve)
        {
        case AnimationCurveEnum.Hermite:
            return(Mathfx.Hermite(start, end, t));

        case AnimationCurveEnum.Sinerp:
            return(Mathfx.Sinerp(start, end, t));

        case AnimationCurveEnum.Coserp:
            return(Mathfx.Coserp(start, end, t));

        case AnimationCurveEnum.Berp:
            return(Mathfx.Berp(start, end, t));

        case AnimationCurveEnum.Bounce:
            return(start + ((end - start) * Mathfx.Bounce(t)));

        case AnimationCurveEnum.Lerp:
            return(Mathfx.Lerp(start, end, t));

        case AnimationCurveEnum.Clerp:
            return(Mathfx.Clerp(start, end, t));

        default:
            return(0);
        }
    }
Пример #3
0
 // Update is called once per frame
 void Update()
 {
     if (bounceActive)
     {
         float t = ((Time.time - startTime) / bounceTime);
         if (t >= 1.0f)
         {
             transform.localPosition = startPosition;
             bounceActive            = false;
         }
         Vector3 currPos = transform.localPosition;
         transform.localPosition = new Vector3(currPos.x, startPosition.y + (Mathfx.Bounce(t) * bounceHeight), currPos.z);
     }
 }
Пример #4
0
    IEnumerator ShakeCoroutine(Vector2 shakeDirection)
    {
        float time = 0;

        while (time < 0.1f)
        {
            transform.localPosition = Vector2.Lerp(shakeDirection, Vector2.zero, Mathfx.Bounce(time / 0.3f));

            time += Time.deltaTime;
            yield return(null);
        }

        transform.localPosition = Vector2.zero;
    }
Пример #5
0
        private float ApplyEasing(float erpPos)
        {
            switch (EaseType)
            {
            case EaseType.In:
                return(Mathfx.Coserp(0, 1, erpPos));

            case EaseType.Out:
                return(Mathfx.Sinerp(0, 1, erpPos));

            case EaseType.InOut:
                return(Mathfx.Hermite(0, 1, erpPos));

            case EaseType.Boing:
                return(Mathfx.Berp(0, 1, erpPos, .5f));

            case EaseType.Bounce:
                return(Mathfx.Bounce(erpPos));
            }

            return(erpPos);
        }
Пример #6
0
 void FixedUpdate()
 {
     transform.position = Mathfx.Bounce(transform.position);
 }