void FixedUpdate() { if (currTime > duration) { state = pingPongState.BACKWARD; } else if (currTime < 0) { state = pingPongState.FORWARD; } if (state == pingPongState.FORWARD) { currTime += Time.deltaTime; } else { currTime -= Time.deltaTime; } fraction = customLerp.getFraction(currTime, duration, type); transform.position = Vector3.Lerp(startPos.position, endPos.position, fraction); }
void Start() { state = pingPongState.FORWARD; }