No description
  • GDScript 67.4%
  • C# 31.6%
  • PowerShell 0.9%
Find a file
2025-03-01 18:41:20 +01:00
.idea/.idea.Cirno/.idea Explosions 2024-06-09 11:45:22 +02:00
.vscode Changes to debug in 4.3 2024-11-11 16:53:28 +01:00
addons Build script 2025-02-24 15:30:19 +01:00
Dialogue Computer fix 2025-02-24 22:30:29 +01:00
fonts Upgrade to godot 4.4 2025-02-24 11:37:45 +01:00
GTweensGodot Added GTWeen 2025-02-24 11:52:50 +01:00
Music Submenus 2025-02-25 21:21:07 +01:00
Resources Credits resource 2025-03-01 14:15:27 +01:00
Scenes Activation controller FSM 2025-03-01 18:41:20 +01:00
Scripts Activation controller FSM 2025-03-01 18:41:20 +01:00
SFX FSM Selector with sound 2025-03-01 18:02:11 +01:00
Shaders Intro panels 2025-02-24 21:40:41 +01:00
Sprites working spder bomb 2025-02-28 11:17:28 +01:00
Tilesets Project upgrade to RC3 2025-02-28 22:50:03 +01:00
.gitattributes initial commit 2024-02-26 08:33:37 +01:00
.gitignore Build script 2025-02-24 17:17:46 +01:00
.gitlab-ci.yml Update .gitlab-ci.yml file to run only on master 2025-02-24 16:34:37 +00:00
Cirno.csproj Project upgrade to RC3 2025-02-28 22:50:03 +01:00
Cirno.csproj.old Updated godot version 2024-05-01 11:51:59 +02:00
Cirno.csproj.old.1 NPC that shoots at player 2024-08-17 17:00:50 +02:00
Cirno.csproj.old.2 NPC that shoots at player 2024-08-17 17:00:50 +02:00
Cirno.csproj.old.3 Upgraded to 4.3 release 2024-08-17 18:11:11 +02:00
Cirno.csproj.old.4 Upgrade to godot 4.4 2025-02-24 11:37:45 +01:00
Cirno.csproj.old.5 Project upgrade to RC3 2025-02-28 22:50:03 +01:00
Cirno.sln initial commit 2024-02-26 08:33:37 +01:00
Cirno.sln.DotSettings.user Debug menu 2025-02-19 13:34:15 +01:00
CONTRIBUTING.md Added GTWeen 2025-02-24 11:52:50 +01:00
CreateIcon.gd Build script 2025-02-24 15:30:19 +01:00
CreateIcon.gd.uid Build script 2025-02-24 15:30:19 +01:00
Export.ps1 Build script 2025-02-24 17:17:46 +01:00
export_presets.cfg Build script 2025-02-24 17:17:46 +01:00
GitVersion.yml Build script 2025-02-24 17:17:46 +01:00
icon.svg initial commit 2024-02-26 08:33:37 +01:00
icon.svg.import initial commit 2024-02-26 08:33:37 +01:00
LICENSE Added GTWeen 2025-02-24 11:52:50 +01:00
nuget.config Added nuget config 2024-05-01 12:23:41 +02:00
omnisharp.json Upgraded to 4.4 RC1 2025-02-27 09:07:24 +01:00
project.godot Inventory Menu 2025-02-25 18:11:57 +01:00
Publish.ps1 Fix user version parameter 2025-02-24 21:56:57 +01:00
README.md Added GTWeen 2025-02-24 11:52:50 +01:00
ReplaceIcon.gd Build script 2025-02-24 15:30:19 +01:00
ReplaceIcon.gd.uid Build script 2025-02-24 15:30:19 +01:00

License: MIT Release NuGet Downloads Tests Twitter Follow Contributions welcome

LogoWide

GTweens-Godot is a lightweight and versatile tweening library for Godot 4 with C#. This library simplifies the process of creating animations and transitions in your Godot projects, allowing you to bring your game elements to life with ease.

Unlike the default Godot tweening engine, which relies on nodes and their string properties to create animations, this tweening engine doesn't require the use of nodes.

An extension that builds upon the GTweens library.

🍰 Features

  • Simple API: GTweens-Godot provides an intuitive and easy-to-use API with C# extension methods.

    public partial class TweenExample : Node
    {
        [Export] public Node2D Target;
    
        public override void _Ready()
        {
            Target.TweenPosition(new Vector2(100, 0), 3)
                .SetEasing(Easing.InOutCubic)
                .Play();
        }
    }
    
  • Sequencing: Easily chain multiple tweens together to create complex sequences of animations.

    public partial class PlayTweenSequenceExample : Node
    {
        [Export] public Node2D Target;
    
        public override void _Ready()
        {
            GTween tween = GTweenSequenceBuilder.New()
                .Append(Target.TweenPositionX(100f, 0.5f))
                    .Join(Target.TweenScale(new Vector2(2f, 2f), 1f))
                .AppendTime(0.5f)
                    .JoinCallback(() => GD.Print("I'm waiting some time!"))
                .Append(Target.TweenPositionX(0f, 1f))
                .AppendCallback(() => GD.Print("I'm finished!"))
                .Build();
    
            tween.SetEasing(Easing.InOutCubic);
            tween.Play();
        }
    }
    
  • Versatile Easing Functions: Choose from a variety of easing functions to achieve different animation effects, including linear, ease-in, ease-out, and custom curves.

    public partial class EasingExample : Node
    {
        [Export] public Node2D Target1;
        [Export] public Node2D Target2;
    
        [Export] public Easing Easing1;
        [Export] public Curve Easing2;
    
        public override void _Ready()
        {
            GTween tween1 = Target1.TweenPositionX(100, 3);
            tween1.SetEasing(Easing1);
            tween1.Play();
    
            GTween tween2 = Target2.TweenPositionX(100, 3);
            tween2.SetEasing(Easing2);
            tween2.Play();
        }
    }
    
  • Looping: Create looping animations with a single line of code, and control loop count and behavior.

    public partial class LoopingTweenExample : Node
    {
        [Export] public Node2D Target;
        [Export] public int Loops;
    
        public override void _Ready()
        {
             GTween tween = Target.TweenPositionX(150, 1);
             tween.SetLoops(Loops);
             tween.Play();
        }
    }
    
  • Delays: Specify delays, allowing precise timing of your animations.

    GTween tween = GTweenSequenceBuilder.New()
        .AppendTime(0.5f)
        .Build();
    
  • Callbacks: Attach callbacks to tweens for event handling at various points in the animation timeline.

    void Callback()
    {
    }
    
    GTween tween = GTweenSequenceBuilder.New()
        .AppendCallback(Callback)
        .Build();
    
  • Async support: GTweens uses the full power of C# and async tasks:

    async Task RunSomething(CancellationToken)
    {
        await tween1.PlayAsync(cancellationToken);
        await tween2.PlayAsync(cancellationToken);
    }
    
  • Godot pause support: GTweens supports changes to GetTree().Paused:

    tween.Play(); // Will be paused when GetTree().Paused is set to true
    tween.PlayUnpausable(); // Won't be paused when GetTree().Paused is set to true
    
  • Safety: When a node that's being tweened becomes invalid or gets destroyed, the tween automatically handles that on a safe manner, and kills itself.

📦 Installation

Form Asset Library

  1. Inside Godot, open the AssetLib tab.

image

  1. Search for and select "GTweens (C#)".

image

  1. Download then install the asset.

  2. On the Godot editor, go to Project/Project Settings/Autoload, and select GTweensGodot/Godot/Source/Contexts/GodotGTweensContextNode.cs to be autoloaded.

From NuGet:

  1. Install the GTweensGodot NuGet package in your godot project.

  2. Create a new node script, anywhere in your project, that's going to update all the tweens. Copy and paste the code from here:

    public partial class GTweensGodotUpdater : GodotGTweensContextNode
    {
    
    }
    
  3. On the Godot editor, go to Project/Project Settings/Autoload, and select the GTweensGodotUpdater.cs we just created, to be autoloaded.

    To quickly check if everything has been setup properly, you can create a new script with this code, and assign any Node2D to the Target export, and play it.

    public partial class TweenExample : Node
    {
        [Export] public Node2D Target;
    
        public override void _Ready()
        {
            Target.TweenPosition(new Vector2(100, 0), 3)
               .SetEasing(Easing.InOutCubic)
               .Play();
        }
    }
    

From releases:

  1. Download the latest GTweensGodot.zip release.
  2. Unpack the GTweensGodot.zip folder into the Godot's project root folder.
  3. On the Godot editor, go to Project/Project Settings/Autoload, and select GTweensGodot/Godot/Source/Contexts/GodotGTweensContextNode.cs to be autoloaded.

Warning

If the example scenes cannot be opened, it probably means that the contents of GTweensGodot.zip were not placed on the root of your project, or that the extracted folder has been renamed. Make sure you don't change the path nor rename any folder, since this will break scene references.

✔️ After installing

Note

(Except on NuGet installation) To quickly check if everything has been setup properly, you can go to GTweensGodot/Godot/Examples/Scenes/ and open any of the example scenes. When you run any of those scenes, a simple functionality example should play.

Note

If after playing an example scene, nothing moves or gets animated, this means that the GodotGTweensContextNode.cs has not been autoloaded. Make sure to properly follow the last installation step.

📚 Getting started

Nomenclature

  • Tween: a generic word that indicates some or multiple values being animated.
  • Sequence: an combination of tweens that get animated as a group.

Prefixes

Prefixes are important to use the most out of IntelliSense, so try to remember these:

  • Tween: prefix for all tween shortcuts (operations that can be started directly from a known object, like a Node2D or a Control).
    node2D.TweenPositionX(100f, 1f);
    control.TweenSizeY(200f, 2f);
    
  • Set: prefix for all settings that can be chained to a tween.
    myTween.SetLoops(4).SetEasing(Easing.InOutCubic);
    
  • On: prefix for all callbacks that can be chained to a tween.
    myTween.OnStart(myStartFunction).OnComplete(myCompleteFunction);
    

Generic tweening

This is the most flexible way of tweening and allows you to tween almost any value.

// For default C# values (int, float, etc)
GTweenExtensions.Tween(getter, setter, to, duration)

// For Godot specific values (Vector2, Vector3, etc)
GTweenGodotExtensions.Tween(getter, setter, to, duration)
  • Getter: a delegate that returns the value of the property to tween. Can be written as a lambda like this: () => myValue where myValue is the name of the property to tween.
  • Setter: a delegate that sets the value of the property to tween. Can be written as a lambda like this: x => myValue = x where myValue is the name of the property to tween.
  • To: the end value to reach.
  • Duration: the duration of the tween in seconds.
  • Validation (optional): a delegate that every time the tween updates, checks if it should be running. Can be written as a lambda like this: () => shouldKeepRunning where shouldKeepRunning is a boolean.
// For default C# values
GTween tween = GTweenExtensions.Tween(
    () => Target.SomeFloat, // Getter
    x => Target.SomeFloat = x, // Setter
    100f, // To
    1 // Duration
);

// For Godot specific values
GTween tween = GTweenGodotExtensions.Tween(
    () => Target.Position, // Getter
    x => Target.Position = x, // Setter
    new Vector2(100f, 100f), // To
    1 // Duration
);

Shortcut tweening

GTweem includes shortcuts for some known C# and Godot objects, like Node2D, Node3D, Control, etc. You can create a tween directly from a reference to these objects, like:

node2D.TweenPositionX(100f, 1f);
node3D.TweenScale(new Vector3(2f, 2f, 2f), 1f);
control.TweenSizeY(200f, 2f);

See all shortcuts you can use.

Sequences

Sequences are a combination of tweens that get animated as a group. Sequences can be contained inside other sequences without any limit to the depth of the hierarchy. To create sequences, you need to use the helper GTweenSequenceBuilder.

  • First you call to start creating a new sequence with GTweenSequenceBuilder.New().
  • Next you Append() or Join() any tweens to the sequence.
    • Append: Adds the given tween to the end of the Sequence. This tween will play after all the previous tweens have finished.
    • Join: Inserts the given tween at the same time position of the last tween added to the Sequence. This tween will play at the same time as the previous tween.
  • Finally you call Build() to get the generated sequence Tween.
 GTween tween = GTweenSequenceBuilder.New()
    .Append(Target.TweenPositionX(100, 0.5f))
        .Join(Target.TweenScale(new Vector2(2, 2), 1))
    .Append(Target.TweenPositionY(100, 1))
    .AppendTime(0.5f)
    .Append(Target.TweenPositionX(0, 1))
    .AppendSequence(s => s
        .AppendTime(0.5f)
        .Append(Target.TweenPositionX(1, 1))
        )
    .AppendCallback(() => GD.Print("I'm finished!"))
    .Build();
        
tween.SetEasing(Easing.InOutCubic);
tween.Play();

As it can be seen on the example, you can Append/Join different things with the builder:

  • Append/Join Callback: adds a callback that will be called when this part of the sequence is executed.
  • Append/Join Time: adds a time delay (in seconds) to the sequence.
  • Append/Join Sequence: creates a new GTweenSequenceBuilder and provides it through the action. Then it automatically builds it and adds the resulting tween to the sequence.

Example of a complex sequence:

ezgif com-gif-maker

Tween controls

  • Play: plays the tween (will be paused if GetTree().Paused is set to true).
  • PlayUnpausable: plays the tween (won't be paused if GetTree().Paused is set to true).
  • Kill: kills the tween. This means that the tween will instantly stop playing, leaving it at its current state.
  • Complete: instantly reaches the final state of the tween, and stops playing.
  • Reset: sets the tween to its initial state, and stops playing.
  • SetLoops: sets the amount of times the tween should loop.
  • SetEasing: sets the easing used by the tween. If the tween is a sequence, the easing will be applied to all child tweens. Set to linear by default.
  • SetTimeScale: sets the time scale that will be used to tick the tween. Set to 1 by default.

Tasks

  • PlayAsync: plays the tween and returns a Task that waits until the tween is killed or completed. If the parameter CancellationToken is cancelled, the tween will be killed.
  • AwaitCompleteOrKill: returns a Task that waits until the tween is killed or completed.

📖 Shortcuts

These are the currently avaliable shortcuts for Godot nodes (the list grows with time).

  • Node2D: GlobalPosition, Position, GlobalRotation, Rotation, GlobalRotationDegrees, RotationDegrees, GlobalScale, Scale, GlobalSkew, Skew.

  • Node3D: GlobalPosition, Position, GlobalRotation, Rotation, GlobalRotationDegrees, RotationDegrees, GlobalScale, Scale.

  • Control: GlobalPosition, Position, Rotation, RotationDegrees, Scale, Size, PivotOffset.

  • Sprite2D: Offset.

  • SpriteBase3D: Modulate, Offset.

  • Light2D: Color, Energy, ShadowColor.

  • Light3D: LightColor, LightEnergy, LightIndirectEnergy, LightVolumetricFogEnergy, LightAngularDistance, ShadowBias, ShadowNormalBias, ShadowTransmittanceBias, ShadowOpacity, ShadowBlur.

  • Camera2D: Offset, Zoom.

  • Camera3D: HOffset, VOffset, Fov.

  • AudioStreamPlayer2D: VolumeDb, PitchScale.

  • AudioStreamPlayer3D: VolumeDb, PitchScale, AttenuationFilterDb, AttenuationFilterCutoffHz.

  • CanvasModulate: Color.

  • CanvasItem: Modulate, SelfModulate.

  • ShaderMaterial: PropertyInt, PropertyFloat, PropertyVector2, PropertyVector2I, PropertyColor.

  • BaseMaterial3D: AlbedoColor, Metallic, MetallicSpecular, Roughness.

    Reddit