WaitForCoroutine node?

FlowCanvas Forums Support WaitForCoroutine node?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #1354

    Hello there! I’m working on a turn-based game and I’m looking to use Flowscript to handle the execution of issued orders (ie ‘go here, perform this animation’ etc; stuff a little specific to each order and better off not being hardcoded). I also need to be able to ‘wait’ for the order to be completed before returning to player control (ie no issuing orders whilst another is still visually being performed!). At current, orders just have a list of ‘execution scripts’ that they run through one by one; move to, turn to, perform animation etc; scriptable objects with an abstract IEnumerator Execute(PotentialOrder info) function; but I’m looking to get this more flexibility and ease-of-use via flowscript.

    Currently, the plan is to have an unbound asset graph that gets passed to an ‘OrderInstance’ prefab with a flowcontroller and the info on the order being performed (who’s performing what where etc). But in the graph itself, I need to be able to wait until a given navigation request / animation etc has been performed, before continuing. I have functions already set up for this from the old implementation; the Navigator for example returns a coroutine so I could just go ‘yield return NavigateTo(pos);’ etc to wait for the navigation order to be completed.

    I know there’s a Wait node, but is there a node to wait for a coroutine to finish execution? I can’t seem to find one; the Coroutine node under FlowControl doesn’t appear to actually take a coroutine as an input. Do I need to create one?

    (from the docs on creating custom nodes, a LatentActionNode<IEnumerator> / <Coroutine> aught to be able to do it, right?)

    EDIT: er… not sure how this ended up in the examples forum; could a kind mod please move this to General Discussion, since it’s a request? Sorry about that.


    With a bit of experimentation:

    These seem to work.
    (as an aside, it would be helpful if the documentation on custom nodes mentioned what namespaces needed including. API reference in general would be greatly appreciated)

    Currently I have it setup thusly:
    A ScriptableObject derived from an ‘Order’ class, that handles ‘how much AP do I cost?’ ‘what icons do I have?’ etc as an asset
    This asset links to a Flowscript graph asset in turn, that visually performs the order
    To execute, we instantiate a new flowscriptcontroller, pass it the graph and info on the order being performed (which unit, the target etc) and wait for it to complete.

    Now all I’d really like to be able to do is pass custom per-order parameters to the graphs. Is there any way to make an asset for pre-defined blackboard variables or anything like that? I can hack up an alternative solution but this would greatly be preferable.



    I am glad you found a solution to what you were after with creating custom nodes. I will add the namespaces in the documentation examples by the way soon. Thanks for suggestion.

    For passing parameters to the graph and considering that the graph is set to respond to some events, you could use the “Custom Event (T)” node for example and then from code you could use the flowScriptController.SendEvent<T>(string name, T value), where T, could of course be some custom made class that would contain all the parameters of the events if more than just one is needed.

    Remember though, that in the case of a custom made class you want to use in FlowCanvas, you will need to add that type in the Preferred Types Editor window, to be possible to actually add a node like for example “Custom Event (MyClass)”.

    Please let me know if the above works for you, or if you need more details about said usage.

    Furthermore, in a later version (soon) of FlowCanvas, asset flowscripts will be able to have and use a local internal blackboard (like Macros do) and thus of course also possible to set these local blackboard variables manually in runtime if required.


    Join us on Discord: https://discord.gg/97q2Rjh


    Apologies for the slow response. For the order execution graphs I actually cheated and just used the OnStart graph event to kick things off.

    Discovered a few quirks with the latent nodes I posted earlier; namely, the Update flow output doesn’t work with them, since it appears to be called for every yield statement (of which there is only one in, say, WaitForIEnumerator and so on). Only way I can think of to work around that would be to start a concurrent timer from the Start port, which seems like one of those things you’d only set up if you needed it; otherwise it would be nice to disable the Update output entirely, but the Update port is registered by LatentActionNodeBase so I don’t think I can do that…?

    I also made another Latent node people might find useful, WaitForCondition:

    Thank you for the assistance! The local blackboard variables in asset graphs sound very welcome.

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