BuddyTween is a lightweight, high-performance, and zero-allocation (for core logic) tweening library for .NET. Built with simplicity in mind, it provides a flexible way to generate eased values for games, UI animations, or data simulations.
- Lightweight: Minimal footprint with no heavy dependencies.
- Enumeration Based: Uses
IEnumerable<float>to allow for easy integration into custom game loops or coroutines. - Extensive Easing Library: Support for Linear, Quad, Cubic, Bounce, Elastic, Sine, Expo, Circ, and Back easing types.
This library has been a core part of my personal development toolkit for many years, powering animations and transitions across numerous private projects. I am now open-sourcing it "as is" for the community to use.
BuddyTween is considered feature-complete. It is stable and battle-tested. Moving forward, primary maintenance will focus on ensuring compatibility with newer .NET versions.
The project is not closed, I'm happy to consider new PRs for new features, optimizations, or additional easing functions.
Install the package via the .NET CLI:
dotnet add package BuddyTweenOr via the NuGet Package Manager:
Install-Package BuddyTweenBuddyTween generates a sequence of values over a specified number of steps. You can iterate through these values to apply them to your objects.
Basic Example (C#) with while
using BuddyTween;
using BuddyTween.Enums;
int durationSteps = 60; // e.g., 60 frames
var tween = BuddyTween.Create(0f, 10f, durationSteps, EaseType.CubicOut);
var tweenEnumerator = tween.GetEnumerator();
while (tweenEnumerator.MoveNext())
{
float currentValue = tweenEnumerator.Current;
Console.WriteLine($"Current Value: {currentValue}");
// Apply currentValue to your Transform, Alpha, or UI element here
}Integration with Unity Coroutines using foreach
IEnumerator StartTween()
{
var tween = BuddyTween.Create(0, 1, 100, EaseType.BounceOut);
foreach (var val in tween)
{
myUIElement.alpha = val;
yield return null; // Wait for next frame
}
}BuddyTween supports a wide array of easing functions to make your animations feel natural, the most common being:
| In | Out | InOut |
|---|---|---|
| QuadIn | QuadOut | QuadInOut |
| CubicIn | CubicOut | CubicInOut |
| BounceIn | BounceOut | - |
| ElasticIn | ElasticOut | ElasticInOut |
| SineIn | SineOut | SineInOut |
Feel free to contribute with new ease functions.
Contributions are welcome, but keep in mind the zero-allocation principle, easy of use and current project standards.
To contribute you should:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the GNU General Public License v2.0. See LICENSE for more information.