// Update is called once per frame void Update() { if (Transforms.Length > 1) { if (BenjasMath.countdownToZero(ref timeToNext)) { factor = (float)animationTime * (1 + Mathf.Lerp(-aniTimeVariation, aniTimeVariation, Random.value)); timeToNext = factor; origin = target; target++; } if (target >= Transforms.Length) { target = 0; } float t; t = BenjasMath.easeInOut(1f - timeToNext / factor); transform.position = Vector3.Lerp(Transforms[origin].position, Transforms[target].position, t); t = BenjasMath.easeInOut(1f - rotationSpeedup * timeToNext / factor); transform.eulerAngles = BenjasMath.angularLerp(Transforms[origin].eulerAngles, Transforms[target].eulerAngles, t); } else { this.enabled = false; } }
private void updateTransition() { visibilityCurrent = Mathf.Clamp01(visibilityCurrent + Time.deltaTime / transitionTime); float t = visibilityCurrent; if (easeIn) { if (easeOut) { t = BenjasMath.easeInOut(t); } else { t = BenjasMath.easeIn(t); } } else if (easeOut) { t = BenjasMath.easeOut(t); } //t goes automaticly backwards when going out trafo.anchoredPosition3D = Vector3.Lerp(transitionVisisbiltyTarget.position, idle.position, t); trafo.localScale = Vector3.Lerp(transitionVisisbiltyTarget.scale, idle.scale, t); setAlpa(Mathf.Lerp(transitionVisisbiltyTarget.alpha, idle.alpha, t)); if (visibilityCurrent == visibilityTarget) { killTransition(); } }