GroveGames.Tween.Godot 0.0.8

dotnet add package GroveGames.Tween.Godot --version 0.0.8
                    
NuGet\Install-Package GroveGames.Tween.Godot -Version 0.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GroveGames.Tween.Godot" Version="0.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GroveGames.Tween.Godot" Version="0.0.8" />
                    
Directory.Packages.props
<PackageReference Include="GroveGames.Tween.Godot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GroveGames.Tween.Godot --version 0.0.8
                    
#r "nuget: GroveGames.Tween.Godot, 0.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=GroveGames.Tween.Godot&version=0.0.8
                    
Install GroveGames.Tween.Godot as a Cake Addin
#tool nuget:?package=GroveGames.Tween.Godot&version=0.0.8
                    
Install GroveGames.Tween.Godot as a Cake Tool

GroveGames.Tween

Build Status Tests Latest Release NuGet

GroveGames.Tween is a lightweight and extensible tweening library for Godot, designed to animate values smoothly over time. It provides an easy-to-use API for creating tweens and sequences, with built-in easing functions for smooth transitions.

Features

  • Flexible Tweening: Tween any type of value, including float, Vector3, and more.
  • Ease Functions: Use predefined easing functions to customize the motion.
  • Sequences: Chain tweens and callbacks for complex animations.
  • Extensions: Built-in support for animating properties of Godot Nodes, such as position, rotation, and scale.
  • Customizable Behavior: Easily add callbacks for updates and completions.

Installation

Using NuGet

To add GroveGames.Tween.Godot to your project, install the NuGet package:

dotnet add package GroveGames.Tween.Godot

Alternatively, use the Package Manager Console in Visual Studio:

Install-Package GroveGames.Tween.Godot

Once installed, ensure that your project references the GroveGames.Tween namespace and its sub-namespaces.


Usage

Basic Tween Example

using Godot;
using GroveGames.Tween.Core;

public class Example : Node3D
{
    private TweenerContext _tweenContext;

    public override void _Ready()
    {
        _tweenContext = new TweenerContext();

        // Move this Node3D to a new position over 2 seconds
        this.MoveTo(new Vector3(5, 5, 0), 2f, _tweenContext)
            .SetOnComplete(() => GD.Print("Move completed!"));
    }

    public override void _Process(float delta)
    {
        // Update tweens
        _tweenContext.Update(delta);
    }
}

Using Sequences

using Godot;
using GroveGames.Tween.Core;

public class SequenceExample : Node3D
{
    private TweenerContext _tweenContext;

    public override void _Ready()
    {
        _tweenContext = new TweenerContext();

        var sequence = _tweenContext.CreateSequence();
        sequence
            .Then(this.MoveTo(new Vector3(5, 5, 0), 2f, _tweenContext, false))
            .Wait(1f)
            .Callback(() => GD.Print("Reached target!"))
            .Play();
    }

    public override void _Process(float delta)
    {
        _tweenContext.Update(delta);
    }
}

Extension Methods

The library includes handy extension methods for Node3D, Node2D, Transform3D, Transform2D, etc. objects. Examples include:

  • MoveTo(Vector3 target, float duration, TweenerContext context)
  • RotateTo(Vector3 targetDegrees, float duration, TweenerContext context)
  • ScaleTo(Vector3 target, float duration, TweenerContext context)

Each method has variations to animate specific axes (e.g., MoveXTo, RotateYTo).


API Reference

Tween Interfaces

ITween
  • void SetEase(EaseType easeType)
  • void SetOnComplete(Action onComplete)
  • void Stop(bool complete)
  • void Update(float deltaTime)
  • void Pause()
  • void Play()
  • bool IsRunning
  • bool IsPlaying
  • float Duration
ITween<T> (Generic)
  • void SetOnUpdate(Action<T> onUpdate)
ISequence
  • ISequence Then(ITween tween)
  • ISequence With(ITween tween)
  • ISequence Wait(float interval)
  • ISequence Callback(Action callback)
  • void Reset()

Customization

Easing Functions

Customize your tweening with easing functions defined in the EaseType enum. Example:

tween.SetEase(EaseType.QuadInOut);

Custom Lerp Functions

Provide your own interpolation function for advanced use cases:

var tween = context.CreateTween(
    () => currentValue, 
    () => targetValue, 
    duration, 
    (start, end, t) => start + (end - start) * t
);

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve this library.


License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.8 454 2 months ago
0.0.7 89 2 months ago
0.0.6 93 2 months ago
0.0.5 349 4 months ago
0.0.4 508 4 months ago
0.0.3 312 4 months ago
0.0.2 106 4 months ago
0.0.1 98 4 months ago