How to make latent nodes from a coroutine?

Forums 💬 FlowCanvas ⚙️ Support How to make latent nodes from a coroutine?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12225
    anton petrov
    Participant

      I have a method returning IEnumerator.

      Is it possible to use this method as a latent node with long execution?

      I was going to use flow script to orchestrate cut scenes and I need a lot of these latent nodes for example to wait while dialogue is showing.

      #12228
      Gavalakis
      Keymaster

        Hello,

        At least right now, IEnumerator methods are not treated in any special way, so they are not automatically treated as a Coroutine (even though that would be a good idea to add 🙂 ).

        However, you could create a wrapper ‘Latent Action Node’ for your IEnumerator method like in the example bellow:

        In the code above we simply wrap an IEnumerator method (CoroutineTest.TestCoroutine) in a FlowCanvas Latent Action Node and have the Invoke method of that node simply ‘yield return’ the started Coroutine from the IEnumerator method.

        Let me know if something like the above works for you.
        Thanks!

        #12227
        anton petrov
        Participant

          Hey Gavalakis,

          As I understood returning function as is from the LatentActionNode also works as expected – no need to StartCoroutine():

          [Category(“Gameplay”)]
          [Description(“Show a dialogue and wait till it end.”)]
          public class ShowDialogue : LatentActionNode
          {
          public override IEnumerator Invoke(string dialogue)
          {
          return Dialogues.ShowDialogue(dialogue);

          }

          public override bool allowRoutineQueueing => false;
          }

          Thank you!

          #12226
          Gavalakis
          Keymaster

            Hey,

            Yes, this also works just fine 🙂

            Thanks!

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.