EasyCoroutine
N

Publisher

noper

EasyCoroutine

Tools
Coroutine Asynchronous Wait Yield Management Framework Scripting Dependency

Core Features: Supports diverse waiting modes: time-based delays (WaitForSeconds), physics frame synchronization (WaitForNextPhysicsFrame), Tween animation completion (WaitForTween), inter-coroutine dependencies (WaitForOtherCoroutine), and custom event locks (WaitForUnlock). Simplified asynchronous programming with yield syntax, enabling and more.sequential-style code execution across frames.

EasyCoroutine - Godot Coroutine Management Plugin

Godot 4.x License: MIT

📦 Installation Guide

  1. Copy the EasyCoroutine folder to your project's addons/ directory
  2. In Godot Editor, navigate to Project Settings -> AutoLoad
  3. Add CoroutineManager.cs as an autoload script (recommended name: CoroutineManager)
  4. Ensure the node exists in scene tree for automatic coroutine system initialization

🛠️ Basic Usage

Starting Coroutines

// Start coroutine in any node
Coroutine.StartCoroutine(TestCoroutine());

IEnumerator TestCoroutine()
{
    GD.Print("Coroutine launched");
    yield return Coroutine.WaitForSeconds(1.5f);
    GD.Print("Executed after 1.5 seconds");
}

Wait Types Reference

Wait Method Description
WaitForSeconds Wait specified seconds
WaitForTimeSpan Wait custom time interval
WaitForNextPhysicsFrame Wait next physics frame
WaitForTween Wait Tween animation completion
WaitForUnlock Wait custom event lock (multi-agent support)
WaitForOtherCoroutine Wait other coroutine completion
WaitForTask Wait task completion
WaitForSignal Wait signal emit

🔗 Examples

Event Lock Mechanism

var attackLock = Coroutine.CreateLock();

IEnumerator AttackSequence()
{
    GD.Print("Charging started");
    yield return Coroutine.WaitForSeconds(2f);
    attackLock.Unlock();
}

IEnumerator WaitAttack()
{
    GD.Print("Waiting for attack completion");
    yield return Coroutine.WaitForUnlock(attackLock);
    GD.Print("Attack released");
}

Tween Coordination

IEnumerator MoveCharacter()
{
    var tween = CreateTween();
    tween.TweenProperty(GetNode("Sprite"), "position", new Vector2(300, 200), 1.5f);
    
    yield return Coroutine.WaitForTween(tween);
    GD.Print("Movement completed");
}

Coroutine Dependency

IEnumerator CoroutineA()
{
    GD.Print("Coroutine A started");
    yield return Coroutine.WaitForSeconds(2f);
    GD.Print("Coroutine A completed");
}

IEnumerator CoroutineB()
{
    GD.Print("Coroutine B started");
    yield return Coroutine.WaitForOtherCoroutine(Coroutine.StartCoroutine(CoroutineA()));
    GD.Print("Coroutine B completed");
}