// Calculates the Sliding Effect when called public static float SlidingEffect(float currentPos, float theTarget, float percentageLeft, float dt = 0) { if (dt == 0) { dt = Time.deltaTime; } float percent = 1 - Mathf.Pow(percentageLeft, dt); return(OrbitalMathAnim.LerpFunc(currentPos, theTarget, percent)); // Uses the lerpFunc to to calculate the lerp, then sends back the value }
public static Vector3 SlidingEffect(Vector3 currentPos, Vector3 theTarget, float percentageLeft, float dt = 0) { if (dt == 0) { dt = Time.deltaTime; } float percent = 1 - Mathf.Pow(percentageLeft, dt); return(OrbitalMathAnim.LerpFunc(currentPos, theTarget, percent)); }
void FixedUpdate() { if (tweenTime < tweenDur) { tweenTime += Time.unscaledDeltaTime * quickerTransition; quickerTransition++; } Vector3 trailingPOS = OrbitalMathAnim.SlidingEffect(transform.position, targetToLock.transform.position, .001f, Time.unscaledDeltaTime); float result = tweenTime / tweenDur; transform.position = OrbitalMathAnim.LerpFunc(trailingPOS, targetToLock.transform.position, Mathf.Clamp(result, 0, 1)); print(result); }