Skip to content

tweens.gd

Coding animations doesn't have to suck.

var hop = new Position2DTween
{ To = to, Duration = 0.9, Ease = EaseType.BackOut };
sprite.Tween(hop);
progress 0.00weight 0.00

A tween in tweens.gd is a definition: one object that names the property, endpoints, timing, and easing together. It reads top to bottom, you can name it and start it from any number of places, and you change it in one spot when the motion should feel different. Refactoring and reauthoring motion become ordinary code edits instead of a hunt through scattered call chains.

static readonly Scale2DTween Pop = new()
{
    From = Vector2.Zero,
    To = Vector2.One,
    Duration = 0.6,
    Ease = EaseType.ElasticOut,
};

Reauthor the definition

coin.Tween(Pop);
gem.Tween(Pop);
sprite.Tween(Pop);

The C# implementation is available in this repository. Start with a project reference or a locally built tweens.gd package while its first public release is pending.

using Godot;
using tweens.gd;
var arrive = new Position2DTween
{
To = new Vector2(400, 180),
Duration = 0.6,
Ease = EaseType.CubicOut,
};
var movement = sprite.Tween(arrive);
if (await movement.Completion == TweenCompletionReason.Completed)
GD.Print("Arrived");

Install the C# library.