DUETween is a framework that allows you to add quick & easy animations to actors in your Unreal Engine games. It provides APIs for both Blueprint and C++ and aims to be flexible, yet memory and runtime efficient.
Current features:
Full plugin is available on Github!
Used to build Yuu Recreations: Bowling
All you have to do is create a tween and it will automatically run on the next frame. Tweens are automatically disposed of either when they end or when the object they’re attached to falls out of scope.
To get you started there are some handy methods to do common tasks like rotation and movement:
// Basic Movement:
DUETween::DueMove(this, TargetLocation, 1.0);
// Basic Rotation:
DUETween::DUERotate(this, TargetRotation, 1.0);
// 2D Movement (for UI elements mainly):
DUETween::DueMove2D(this, Target2DLocation, 1.0);
Every tween can be used with any of the available easing functions:
DUETween::DueMove(this, TargetLocation, 1.0, EDueEasingType::Linear);
If you have a specific property on a UObject you want to tween you can reference it by name:
DUETween::StartDUETween<float>(this,"MyProperty", 50.0, 1.0);
Each tween returns a handle that you can use to control playback as well as modify tween properties:
FActiveDUETweenHandle Handle = DUETween::DueMove(this, TargetLocation, 1.0);
// Stop and cancel tween
Handle.StopTween();
// Pause and resume tween
Handle.PauseTween();
Handle.Resume();
// Updates the step count (chunkiness) of the tween
Handle.SetSteps(10);
// Updates whether or not this tween should yoyo (return to it's starting position)
Handle.SetYoYo(true);
// Updates Number Of Loops this tween will do before completing (-1 = infinite)
Handle.SetLoopCount(-1);
// Binds a completion event
FTweenCompleteCallback& CompletionCallback;
Handle.OnComplete(CompletionCallback);
(C++ Only) You can also use Lambdas for custom tweens, here’s an example where I use a lambda tween to evaluate a custome curve:
const FVector TargetLocation = BallGripStartPosition.GetValue() + GetActorForwardVector() *
StartDistance;
const FVector StartPosition = BallGripStartPosition.GetValue();
FTweenUpdateCallback TargetCallback = [TargetLocation,StartPosition,Curve = RunUpCurve.GetRichCurveConst(), this](
const FValueContainer& UpdatedValue)
{
const FVector CurrentLocation = FMath::Lerp(StartPosition, TargetLocation,
Curve->Eval(UpdatedValue.GetSubtype<float>()));
this->SetActorLocation(CurrentLocation);
};
DUETween::StartDUETween<float>(this, TargetCallback, 0.0, 1.0, RunUpTimeMS);
The Blueprint API Currently Supports:
Example of all the available nodes
Example of using the float field tween to animate a progress bar in and out
Made with: Unreal Engine, C++
Role: Sole Developer
I built DUETween primarily because I fell in love with DOTween while making Unity games and couldn’t find any existing plugins in Unreal that replicated it’s power and ease of use.
Initially it started as a collection of blueprint functions I had written but eventually it grew into a full C++ plugin. Throughout development I tried to keep the API as simple and flexible as I could for both C++ and Blueprint while still providing good performance wherever I could get it.
DUETween runs in a world subsystem that tracks and updates a linked list of active running tweens in a compact pool that I manually manage the memory for. The pool uses a free-list allocated within the pool itself to track available slots as new tweens come in, this makes it fast to create tweens in order to avoids frame time spikes, but does lead to some amount of fragmentation over time which could slightly degrade performance as we jump around the allocated pool. Each tween in the pool is about 272 bytes (squished together as tightly as I could get them). The pool itself can grow as new tweens come in (up to a limit) and users can set the parameters for the pool’s initial size, growth factor, and max size.
I tested DUETween not only in a stress-test scene and various prototypes but also in my game Yuu Recreations: Bowling where it’s used for most of the (non-skeletal) animations in the game like the UI buttons bouncing, the run-up motion of the bowler, the pin-sweep, and much more!