Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Possible to make a Subgraph support coroutines?

Discussion in 'Visual Scripting' started by literacy, Oct 25, 2022.

  1. literacy

    literacy

    Joined:
    Nov 14, 2021
    Posts:
    35
    I have a Subgraph with a "Wait For Seconds" node... so I need to make sure it supports coroutines (or, rewrite my code).

    Normally I just look at the Event Node (On Start, On Update, etc.) and check off the "coroutine" checkbox (see attached).

    Is it possible to do something similar for a Subgraph?
     

    Attached Files:

  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,034
    If you pass on the regular event flow that's marked as coroutine to a subgraph, it'll still work.

    Or use Timer and Cooldown nodes which have built in coroutines and don't need the coroutine checkbox. Note that Wait For Seconds and similar simple time related nodes won't work if wired after Timer or Cooldown nodes.

    Lastly, you can implement your own coroutine nodes in C#.

    The subgraph itself doesn't have any kind of coroutine functionality or checkboxes. It's handled either on the whole flow level with the checkbox on a green flow starting event node or with individual time related nodes like Timer/Cooldown/custom implemented coroutine nodes.
     
    REDACT3D_ likes this.
  3. literacy

    literacy

    Joined:
    Nov 14, 2021
    Posts:
    35
    Thank you very much! I marked all the relevant Event nodes as supporting coroutines, and it worked perfectly! Much appreciated...
     
    REDACT3D_ likes this.
  4. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    timer is my fave.

    you can even retrigger the timer to start again like a loop
    but you can't connect the Completed Directly to the Start, need to place one node between
    thought that was kinda weird at first but now think about it automatically



    Capture.PNG