A lightweight tweening library for Unreal Engine.
NsTween moves a value from a start to an end over time, with an easing curve. Use it from C++ with FNsTween::Play, or from Blueprint with async nodes. It suits UI motion and small game motion, such as a floating pickup, a door, or a color pulse.
NsTween does not replace UMG animations or Sequencer, and it does not replicate. Tweens run on real time, so a game pause or a time dilation does not slow them.
OnComplete, OnLoop, and OnPingPong in C++, and the same events on the async nodes.Play ... Tween nodes that take a full spec.NsTween folder into the Plugins folder of your project."NsTween" to the dependencies of your game module.In C++, FNsTween::Play returns a builder. Chain the options in the same statement. The tween starts when the builder goes out of scope.
#include "NsTween.h"
void AMyActor::BeginPlay()
{
Super::BeginPlay();
const FVector Start = GetActorLocation();
FNsTween::Play(0.f, 100.f, 2.f, ENsTweenEase::InOutQuad, [this, Start](float Value)
{
SetActorLocation(Start + FVector(Value, 0.f, 0.f));
})
.SetOwner(this);
}
In Blueprint:
Tween Float node.| Node | Output |
|---|---|
Tween Float, Tween Vector, Tween Vector 2D |
The value on Apply Easing |
Tween Rotator, Tween Quat, Tween Quat From Rotator |
A Rotator or a Quat on Apply Easing |
Tween Transform, Tween Linear Color |
The value on Apply Easing |
... Custom Curve versions |
The same, with a Float Curve as the ease |
Play Float Tween, Play Vector Tween, Play Rotator Tween, Play Transform Tween, Play Color Tween |
A handle. The tween writes to the Target variable |
Pause Tween, Resume Tween, Cancel Tween, Is Tween Active |
Control by handle |
FNsTween::Play โ Make a tween from a start, an end, a duration, an ease, and an update function. A second overload takes an FNsTweenSpec and a value strategy factory.FNsTweenBuilder โ Set the options: SetLoops, SetPingPong, SetDelay, SetTimeScale, SetCurveAsset, SetOwner, OnComplete, OnLoop, OnPingPong.FNsTweenBuilder control โ Pause, Resume, Cancel, IsActive, GetHandle.FNsTweenSpec โ The Blueprint struct with all the options of one tween.FNsTweenHandle โ The id of one tween.ENsTweenEase โ The easing presets, plus CustomBezier and CurveAsset.UNsTweenBlueprintLibrary โ The Play ... Tween and control nodes.UNsTweenAsyncAction โ The base class of the async tween nodes.UNsTweenSequence holds a list of specs, but no code plays it.NsTween takes its inspiration from Fresh Cooked Tweens by Jared Cook.