// Update is called once per frame void FixedUpdate() { if (Input.GetButtonDown("Jump")) { Vector2 pos = _rb.position; pos.x = EasingFunction.EaseInExpo(pos.x, pos.x + 5, pos.x); _rb.MovePosition(pos); } }
void DrawCurve() { if (drawIt == false) { return; } lineRenderer.material.SetColor("_TintColor", new Color(Color.r, Color.g, Color.b, 0.5f)); float t = 0; currentTime += Time.deltaTime; float pa = EasingFunction.EaseInExpo(0, 1, currentTime / duration); for (int j = 0; j < curveCount; j++) { for (int i = 1; i <= SEGMENT_COUNT; i++) { // 控制曲線繪圖進度(動畫) // Fixme:不易閱讀 t = i / (float)SEGMENT_COUNT; t = t >= pa ? pa : t; int nodeIndex = j * 3; Vector3 pixel = CalculateCubicBezierPoint(t, controlPoints[nodeIndex].position, controlPoints[nodeIndex + 1].position, controlPoints[nodeIndex + 2].position, controlPoints[nodeIndex + 3].position); lineRenderer.positionCount = (((j * SEGMENT_COUNT) + i)); lineRenderer.SetPosition((j * SEGMENT_COUNT) + (i - 1), pixel); transform.Find("LightStar").position = pixel + Vector3.up * 0.5f; } } lineRenderer.SetPosition(0, controlPoints[0].position);// 讓線條起點在生物身上 p0.position = controlPoints[0].position + Vector3.up * (5 + Mathf.Clamp(10 - Vector3.Distance(controlPoints[0].position, controlPoints[3].position), 0, 10)); p0.transform.position -= Vector3.up * 1.5f * currentTime; if (t < 1) { return; } currentTimeAlpha += Time.deltaTime; alpha = EasingFunction.Linear(0.5f, 0, currentTimeAlpha / 1); alpha = alpha < 0 ? 0 : alpha; lineRenderer.material.SetColor("_TintColor", new Color(Color.r, Color.g, Color.b, alpha)); if (alpha > 0f) { return; } currentTimeAlpha = 0; currentTime = 0; drawIt = false; SetColor("Hide"); }
private void HPWhiteAnimation() { if (1 - HPValue.fillAmount < HPWhite.fillAmount) { ShowHPHeader(); HideHPRed(); ShowHPWhite(); HPWhite.fillAmount = EasingFunction.EaseInExpo(HPWhite.fillAmount, 1 - HPValue.fillAmount, HPWhite_t += Time.deltaTime / 0.25f); } else { HideHPHeader(); HPWhite.fillAmount = 1 - HPValue.fillAmount; } }
private Vector3 SmoothMove() { if (t <= 1.0) { t += Time.deltaTime / currentSeconds; float newTime = t; if (newTime > 1) { newTime = 1; } float easeFactor = newTime; if (easing == EASING_FUNCTION.INOUTCUBIC) { easeFactor = EasingFunction.EaseInOutCubic(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.BOUNCE) { easeFactor = EasingFunction.EaseOutBounce(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.ELASTIC) { easeFactor = EasingFunction.EaseOutElastic(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.EXPO) { easeFactor = EasingFunction.EaseInExpo(0.0F, 1.0F, newTime); } Vector3 newPosition = Vector3.Lerp(currentStartPos, currentEndpos, easeFactor); Vector3 pixelPerfectMoveAmount = Utils.MakePixelPerfect(newPosition); return(pixelPerfectMoveAmount - transform.position); } isMoving = false; return(Vector3.zero); }
private void SmoothMove() { if ((t <= 1.0) || (seconds == 0)) { t += Time.deltaTime / seconds; float newTime = t; if (newTime > 1) { newTime = 1; } float easeFactor = 0; if (easeFunction == EASE_FUNCTION.EASEOUTBOUNCE) { easeFactor = EasingFunction.EaseOutBounce(0.0F, 1.0F, newTime); } if (easeFunction == EASE_FUNCTION.EASEINEXPO) { easeFactor = EasingFunction.EaseInExpo(0.0F, 1.0F, newTime); } if (easeFunction == EASE_FUNCTION.EASEOUTEXPO) { easeFactor = EasingFunction.EaseOutExpo(0.0F, 1.0F, newTime); } Vector2 newPosition = Vector2.Lerp(startPos, endPos, easeFactor); Vector3 pixelPerfectMoveAmount = Utils.MakePixelPerfect(newPosition); transform.Translate(pixelPerfectMoveAmount - transform.position); } else { isMoving = false; if (remove) { characterController.DestroyCharacters(); } } }
private Vector3 SmoothMove() { if (t <= 1.0) { t += Time.deltaTime / GetCurrentSeconds(); float newTime = t; if (newTime > 1) { newTime = 1; } float easeFactor = newTime; EASING_FUNCTION easing = GetCurrentEasing(); if (easing == EASING_FUNCTION.INOUTCUBIC) { easeFactor = EasingFunction.EaseInOutCubic(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.BOUNCE) { easeFactor = EasingFunction.EaseOutBounce(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.ELASTIC) { easeFactor = EasingFunction.EaseOutElastic(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.INEXPO) { easeFactor = EasingFunction.EaseInExpo(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.OUTEXPO) { easeFactor = EasingFunction.EaseOutExpo(0.0F, 1.0F, newTime); } Vector3 newPosition = Vector3.Lerp(currentStartPos, currentEndpos, easeFactor); Vector3 pixelPerfectMoveAmount = Utils.MakePixelPerfect(newPosition); return(pixelPerfectMoveAmount - transform.position); } if (currentEndpos == endpos && myRenderer.isVisible) { ActionCompleteEffect(); } isMoving = false; isMovingAction = false; isMovingPrewarm = false; if (currentEndpos == endpos) { waitUntil = Time.timeSinceLevelLoad + waitTimeActionPosition; currentStartPos = endpos; currentEndpos = startPos; } else { if (currentEndpos == prewarmPos) { PrewarmEffect(); isMovingAction = true; waitUntil = Time.timeSinceLevelLoad + waitTimePrewarmPosition; currentStartPos = prewarmPos; currentEndpos = endpos; } else { isMovingPrewarm = true; waitUntil = Time.timeSinceLevelLoad + waitTimeBasePosition; currentStartPos = startPos; currentEndpos = prewarmPos; } } return(Vector3.zero); }
private Vector3 SmoothMove() { if (t <= 1.0) { t += Time.deltaTime / GetCurrentSeconds(); float newTime = t; if (newTime > 1) { newTime = 1; } float easeFactor = newTime; EASING_FUNCTION easing = GetCurrentEasing(); if (easing == EASING_FUNCTION.INOUTCUBIC) { easeFactor = EasingFunction.EaseInOutCubic(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.BOUNCE) { easeFactor = EasingFunction.EaseOutBounce(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.ELASTIC) { easeFactor = EasingFunction.EaseOutElastic(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.INEXPO) { easeFactor = EasingFunction.EaseInExpo(0.0F, 1.0F, newTime); } if (easing == EASING_FUNCTION.OUTEXPO) { easeFactor = EasingFunction.EaseOutExpo(0.0F, 1.0F, newTime); } if (isMovingAction && Time.frameCount % 2 == 0) { InstantiateEffect(fallingEffect, transform.position); } Vector3 newPosition = Vector3.Lerp(currentStartPos, currentEndpos, easeFactor); Vector3 pixelPerfectMoveAmount = Utils.MakePixelPerfect(newPosition); if (!actionCompleteEffectPlayed && ((easing != EASING_FUNCTION.BOUNCE && newPosition == endpos) || (easing == EASING_FUNCTION.BOUNCE && (newPosition.y > transform.position.y)))) { ActionCompleteEffect(); } return(pixelPerfectMoveAmount - transform.position); } isMoving = false; isMovingAction = false; isMovingPrewarm = false; if (currentEndpos == endpos) { waitUntil = waitUntil + secondsAction + waitTimeActionPosition; currentStartPos = endpos; currentEndpos = startPos; actionCompleteEffectPlayed = false; } else { isMovingPrewarm = true; waitUntil = waitUntil + secondsBase + waitTimeBasePosition; currentStartPos = startPos; currentEndpos = endpos; } return(Vector3.zero); }