Convenient curve functions to ease a value between a start and end, like positions, scales, colors, anything you want to smoothly change.
NsTween is a small yet powerful tweening framework for Unreal Engine. It allows smooth interpolation of floats, vectors and quaternions using a rich set of easing functions. Tweens can be controlled entirely through C++ or Blueprint nodes.
float
, vector
, vector2D
, rotator
and quaternion
values.Unreal Engine 5.2+
NsTween
folder into your projectβs Plugins
directory.Below is a minimal C++ example showing how to move an actor along the X axis using NsTweenCore
:
#include "NsTweenCore.h"
void AMyActor::BeginPlay()
{
Super::BeginPlay();
NsTweenCore::Play(
/**Start*/ 0.f,
/**End*/ 100.f,
/**Time*/ 2.f,
/**Ease*/ ENsTweenEase::InOutQuad,
/**Update*/ [this](float Value)
{
SetActorLocation(FVector(Value, 0.f, 0.f));
});
}
The library also exposes Blueprint nodes for the same functionality if you prefer a visual approach. Below is a slightly more advanced snippet showing how to make an item float up and down while spinning for 10 complete loops
#include "NsTweenCore.h"
void AFloatingItem::BeginPlay()
{
Super::BeginPlay();
// Float continuously
NsTweenCore::Play(
/**Start*/ GetActorLocation().Z,
/**End*/ GetActorLocation().Z + 40.f,
/**Time*/ 1.f,
/**Ease*/ ENsTweenEase::InOutSine,
/**Update*/ [this](float Z)
{
FVector CurrentLocation = GetActorLocation();
CurrentLocation.Z = Z;
SetActorLocation(CurrentLocation);
})
.SetPingPong(true)
.SetLoops(-1); // infinite loops
// Rotate and print 10 times the Loop
NsTweenCore::Play(
/** Start */ 0.f,
/** End */ 360.f,
/** Time */ 2.f,
/** Ease */ ENsTweenEase::Linear,
/** Update */ [this](float Yaw)
{
SetActorRotation(FRotator(0.f, Yaw, 0.f));
})
.SetLoops(10) // 10 full spins
.OnLoop([this]()
{
UE_LOG(LogTemp, Warning, TEXT("Spin finished"));
});
}
NsTweenCore
β static helpers to play tweens in C++.UNsTweenSubsystem
β automatically ticks and manages active tweens.UNsTweenAsyncAction
β base class for asynchronous Blueprint tween nodes.UNsTweenBlueprintLibrary
β utility functions including Ease
helpers.NsTweenCore::Play
β start a tween in C++ for various types.UNsTweenAsyncActionFloat::TweenFloat
β Blueprint node to tween a float value.UNsTweenAsyncActionVector::TweenVector
β Blueprint node to tween vectors.NsTweenInstance
β represents a single tween instance with control methods.