Start/Stop BTOwner by script

Forums 💬 NodeCanvas ⚙️ Support Start/Stop BTOwner by script

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17209
    derdicke
    Participant

      Hi again,

      I’m writing an AI toolset for Unity Asset Store and want to support NC.
      I would like to be able to ‘start’ (by enabling it?) a BTO and let the user stop it with an action inside NC and notify my script.
      This action should be written by me and not some user assembled complicated flow of actions. Just some kind of ‘Reset BTO, disable it and notify my script that it is done.
      Use case is to branch to a BTO to calculate a decision, store the outcome (this part is already done), reset and disable BTO and notify my script that it has finished the calculation.

      The enabling part is simple, but i don’t see the way how to code the DisableResetNotify Action.
      Also I’m not that sure if it makes sense at all to use NC this way…

      Any input welcome.

      #17211
      Gavalakis
      Keymaster

        Hello again,

        Considering I understood correctly, this is actually pretty easy to do 🙂

        The BehaviourTreeOwner (or any GraphOwner for that matter), has a “StartBehaviour” overload that takes a System.Action<bool> argument as a callback. As such, when (for any reason, even by the included ControlGraphOwner action task) the behaviour is stopped, the callback will be called. For example:

        Thus the “trick” here, is simply to provide a callback when the behaviour starts. Ending the behaviour can be done in any way and the callback will still be called.

        Please let me know if that works for you.
        Thanks!

        #17210
        derdicke
        Participant

          Works like a charm.
          Thanks alot!

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