Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

C# Coroutines like Unity

An asset by Peaky
The page banner background of a mountain and forest
C# Coroutines like Unity hero image

Quick Information

0 ratings
C# Coroutines like Unity icon image
Peaky
C# Coroutines like Unity

* Coroutines with pararmaters. * Yield until next frame. * Yield for certain amount of time in seconds. * Yield another coroutine.

Supported Engine Version
4.1
Version String
1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

GodotCoroutineslikeUnity

C# Coroutines in Godot game engine just like in Unity

  1. Add PeakyCoroutine.cs somewhere in your project

  2. Use like this...

    public override void _Ready()
    {
        Coroutine.Run(TestCoroutine(3f), this);
    }
    
    IEnumerator TestCoroutine(float waittime)
    {
        GD.Print("Start " + Time.GetTicksMsec());
        yield return new WaitForSeconds(1f);
        GD.Print("WaitedOneSecond " + Time.GetTicksMsec());
        yield return new WaitForSeconds(1f);
        GD.Print("WaitedAnotherSecond " + Time.GetTicksMsec());
    
        for (int i = 0; i < 20; i++)
        {
            yield return new WaitOneFrame();
            GD.Print("Waited One frame " + Time.GetTicksMsec());
        }
    
        yield return TestSubCoroutine(waittime);
    
        GD.Print("Final line from parent coroutine");
    }
    
    IEnumerator TestSubCoroutine(float waittime)
    {
        GD.Print("start sub routine " + Time.GetTicksMsec());
        yield return new WaitForSeconds(waittime);
        GD.Print("end sub routine " + Time.GetTicksMsec());
    }
    

I wanted to replicate the following features..

  • Coroutines with pararmaters.
  • Yield until next frame.
  • Yield for certain amount of time in seconds.
  • Yield another coroutine.


* Coroutines with pararmaters.
* Yield until next frame.
* Yield for certain amount of time in seconds.
* Yield another coroutine.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
C# Coroutines like Unity icon image
Peaky
C# Coroutines like Unity

* Coroutines with pararmaters. * Yield until next frame. * Yield for certain amount of time in seconds. * Yield another coroutine.

Supported Engine Version
4.1
Version String
1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers