Tweening library for Unreal Engine with a fluent C++ API and Blueprint nodes
TypeTween::Tween<float>(this)
.From(0.0f)
.To(10.0f)
.Duration(2.5f)
.Ease(ETweenEase::Linear);
// Tween an existing value (you manage the lifetime of the variable)
TypeTween::Tween(MyValue, this)
// Tween an internally-owned value (fire and forget)
TypeTween::Tween<float>(this)
// Tween with an initial value (type deduced)
TypeTween::Tween(FVector::ZeroVector, this)
// Tween an actor's transform
TypeTween::Tween(MyActor)
// Timing-only tween (no value)
TypeTween::Tween(this).From(startValue) // start value (defaults to current value if omitted)
.To(endValue) // end value
.By(delta) // relative end: To = From + ByEasing (Easings.net)
.Ease(ETweenEase::OutBounce)| Family | Variants |
|---|---|
| Linear | Linear |
| Sine | InSine OutSine InOutSine |
| Quad | InQuad OutQuad InOutQuad |
| Cubic | InCubic OutCubic InOutCubic |
| Quart | InQuart OutQuart InOutQuart |
| Quint | InQuint OutQuint InOutQuint |
| Expo | InExpo OutExpo InOutExpo |
| Circ | InCirc OutCirc InOutCirc |
| Back | InBack OutBack InOutBack |
| Elastic | InElastic OutElastic InOutElastic |
| Bounce | InBounce OutBounce InOutBounce |
.Repeat(3) // play 4 times total (default: 0 = once)
.Repeat(-1) // Repeat infinitly until stopped
.PingPong(false) //(Default) 0 -> 1, 0 -> 1...
.PingPong(true) // 0 -> 1 -> 0....Duration(2.0f) // animation length in seconds (required)
.StartDelay(0.5f) // wait before starting
.ReverseDelay(0.3f) // ping-pong: pause between forward and reverse phases
.RepeatDelay(0.2f) // pause between repeat cycles
.EndDelay(0.1f) // pause after the final cycle before OnComplete fires.OnPreStart([]() { }) // very first frame, before StartDelay
.OnStart([]() { }) // after StartDelay elapses
.OnCycleBegin([]() { }) // start of each cycle
.OnForwardEnd([]() { }) // forward phase complete (alpha == 1)
.OnReverseBegin([]() { }) // ping-pong: reverse phase begins
.OnCycleEnd([]() { }) // end of cycle
.OnRepeat([]() { }) // each repeat except the last
.OnComplete([]() { }) // all cycles finished
.OnTick([]() { }) // every frame, including delays
.OnUpdate([](float Alpha, const T& Value) { }) // typed, during interpolationClick the ▼ arrow for more settings and callbacks:
Handles keep a tween alive and let you control it after creation:
TypeTween::FTweenHandle Handle = TypeTween::Tween<float>(this)
.To(1.f)
.Duration(2.f);
Handle->Pause();
Handle->Resume();
Handle->Restart();
Handle->Finish(); // jump to end state immediately
Handle->IsDone();
Handle.Reset(); // release handle (tween is destroyed if no other refs remain)Types like int, double, float, FVector, FRotator all supported by default:
TypeTween::Tween<int>(this).From(0).To(100);
TypeTween::Tween<double>(this).From(0.0).To(1.0);
TypeTween::Tween<float>(this).From(0.0f).To(1.0f);
TypeTween::Tween<FVector>(this).From(FVector::ZeroVector).To(FVector(1.f, 2.f, 3.f));
TypeTween::Tween<FRotator>(this).From(FRotator::ZeroRotator).To(FRotator(45.f, 90.f, 180.f));Some Types have custom functionality or helper functions:
FTransform has custom From()/To() functions for each component:
// Default:
TypeTween::Tween<FTransform>(this).From(StartTransform).To(EndTransform);
// Helper Functions:
TypeTween::Tween<FTransform>(this)
/* Move */
.MoveFrom(FVector(0.f, 0.f, 0.f))
.MoveTo(FVector(100.f, 0.f, 0.f))
/* Rotate */
.RotateFrom(FRotator::ZeroRotator)
.RotateTo(FRotator(0.f, 90.f, 0.f))
/* Scale */
.ScaleFrom(FVector(1.f, 1.f, 1.f))
.ScaleTo(FVector(2.f, 2.f, 2.f));Colors can be interpolated/lerped in different ways.
TypeTween::Tween<FLinearColor>(this)
.From(FLinearColor::Yellow)
.To(FLinearColor::Blue)
/* Specify color interpolation mode: */
.LerpMode(EColorLerpMode::sRGB)
.LerpMode(EColorLerpMode::Linear)
.LerpMode(EColorLerpMode::HSV)
.LerpMode(EColorLerpMode::Oklab)