Write Faster Code with Coroutines in Godot 4.2 and 3.5

Поделиться
HTML-код
  • Опубликовано: 11 июл 2024
  • There was quite a large leap between how coroutines are handled in Godot 3.5 and Godot 4.2. Instead of Yield, which was used in Godot 3.5, the new Await keyword is being used in Godot 4.2.
    This video aims to cover what coroutines are, how to use them in Godot 4.2 with Await, how to use them in Godot 3.5 with yield, the differences between await and yield, how to migrate from Godot 3.5 to Godot 4.2 and finally some bad practices you should avoid while working with coroutines.
    There have been a lot of useful details about coroutines I found while researching this video. Additionally, I have also used some free assets for which I can't be thankful enough. Here are the links for everything:
    Official Godot 4.2 documentation for the Await keyword: docs.godotengine.org/en/stabl... (sometimes this link doesn't work properly. An easy fix is to scroll down or search for 'coroutines' to find the docs about await)
    Official Godot 3.5 documentation for the Yield function: docs.godotengine.org/en/3.5/t...
    Extra useful GDScript blog post about coroutines: gdscript.com/solutions/corout...
    Discussion regarding the change from Yield to Await and the lack of support for a way to resume a coroutine, similarly to how it was possible with Yield: github.com/godotengine/godot-...
    Godot 4.2 coroutines repository which helps replicate the previous Yield behavior: github.com/BimDav/Godot4-Coro...
    Link for a simple coroutine wrapper: forum.godotengine.org/t/i-don...
    Helpful coroutines tutorial from ‪@GodotTutorials‬ : • Coroutines | Godot GDS...
    Dino character: arks.itch.io/dino-characters
    Cars used from city pack: nyknck.itch.io/citypackpixelart
    Thumbnail uses assets from Lethal Company: store.steampowered.com/app/19...
    I'm again, extra thankful for all the free information and assets. This video wouldn't have been possible without your help!
    --------------------
    Github repository for this project. Contains links from the description and the two migration example code documents:
    github.com/cashew-olddew/godo...
    Support me on Ko-Fi: ko-fi.com/cashewolddew
    --------------------
    Chapters:
    0:00 What will you learn?
    0:22 What is a coroutine?
    1:12 Using the await keyword in Godot 4.2
    8:55 Using the yield function in Godot 3.5
    17:50 Migrating from Godot 3.5 to Godot 4.2
    19:00 Bad practices when using coroutines
    Footnote: Sorry for the ASMR in this video. I was a bit too close to the microphone 😞
    #gamedev #godot #tutorial

Комментарии • 8

  • @sloppyglizzy8313
    @sloppyglizzy8313 4 месяца назад +7

    Thanks for making this video. I love when people take the time to properly explain concepts. I’m a big picture person and when I don’t understand the why I completely lose sight of everything else. Great descriptions, great focus on showing what you’re doing while you’re doing it. This is the best part for me. Some tutorials Blaze through assuming we know. But the issue there is I wouldn’t need a tutorial if I already knew! So I extend my sincerest thank you.

    • @cashewolddew
      @cashewolddew  4 месяца назад +2

      I'm really happy to see comments like this. I'm glad to know I'm heading towards the right direction. Thanks a lot for the kind words 🥜

  • @grzegorzpedrycz2630
    @grzegorzpedrycz2630 3 месяца назад +2

    I just start thinking about how asynchronous operation work in Godot... Thanks for lovely piece of knowledge !

  • @MH-lr6ue
    @MH-lr6ue 3 месяца назад +1

    Thank you. This was very easy to digest

  • @sloppyglizzy8313
    @sloppyglizzy8313 4 месяца назад

    Can I use await inside of an area2d signal? Specifically I have a script where my enemy follows my character when they’re in range. However, even though my character isn’t in range the enemy automatically starts approaching. Not sure why this is because I used an if statement with something like:
    If body.in_group=“player”:
    - not on my pc at the moment but I would be interested to see if await could be used to fix my issue.

    • @cashewolddew
      @cashewolddew  4 месяца назад +1

      You can, of course, wait for a signal, but from the sound of it, it seems that you only want to approach when in range. In that case you could connect the function which makes the enemy seek your character to the body_entered signal of your Area2D. Thus, the character would follow only when entering some area that you define around your character.
      I know about this amazing tutorial ruclips.net/video/MtEh6vofiqQ/видео.html from Queble which tries to achieve what you describe.

  • @colly6022
    @colly6022 2 месяца назад

    why the lethal company screenshot in the thumbnail? 🤔

    • @cashewolddew
      @cashewolddew  2 месяца назад +2

      Well, since this is a coroutine video, I thought it fitting since the game has YIELD sign.