Execute and wait for behaviour bundle to finish

  • Is there a way to execute (behaviour on) a behaviour bundle, and wait for it to finish running before continuing the main code.


  • Use broadcast message and receive message. They work like "functions" where code will only continue to run after all the code in the receive message behavior has been executed.

    Broadcast message to call an event (you can put parameters in it too!) and receive message to handle the event.

  • How I’d do it: After the calculated result behaviour wherever it is, behaviour on the thing that does stuff with the calculated result. So you would disconnect Get Calculated Result and turn it off.

  • Since I'll be using the "calculate result" function multiple times in different places, I think the best option is:

    • Use broadcast/receive message. When using "calculate result", supply a parameter that says the name of the "receive message" key to activate (basically a callback function)

    Which is similar to the separated behaviour bundle + "behaviour on" technique.

    If I could dynamically supply the name of what behaviour bundle I want to activate, then I would choose to do that, since having multiple "receive message" might have a tiny performance impact.

  • @Kamdroid Just after doing some testing, for me the game seems to always actually wait for the calculation to finish before moving on to the next behaviour under behaviour on anyway, even when calculate result had loops.

Log in to reply