public void MoveToLocal(Vector2 position, MadiTween.EaseType easeType, float time) { if (time == 0) { cameraPos = MadMath.ClosestPoint(dragBounds, position); moveAnim = false; } else { moveAnimStartPosition = cachedCamPos; moveAnimEndPosition = position; moveAnimStartTime = Time.time; moveAnimDuration = time; moveAnimEaseType = easeType; moveAnim = true; } }
void UpdateMoving() { if (!moveAnim) { return; } if (moveAnimStartTime + moveAnimDuration > Time.time) { float percentage = (Time.time - moveAnimStartTime) / moveAnimDuration; cachedCamPos = Ease(moveAnimEaseType, moveAnimStartPosition, moveAnimEndPosition, percentage); } else { cachedCamPos = moveAnimEndPosition; moveAnim = false; } cachedCamPos = MadMath.ClosestPoint(dragArea, cachedCamPos); }