Proper handling of BehaviourTreeOwner destruction

Forums 💬 NodeCanvas 🗨️ General Discussion Proper handling of BehaviourTreeOwner destruction

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

      Hi,

      I think there is a design problem with GraphOwner destruction, here is the case:

      ActionTask.OnStop() is supposed to do something to finalize current task. In my case ActionTask was responsible for character walking and in its OnStop() it removes walking animation so the character starts playing an idle animation.

      The problem is when the character is destroyed, OnDestroy is called for each MonoBehaviour including BehaviourTreeOwner. And this calls OnStop() for action tasks. And during OnStop() my code starts a corouting and Unity throws an error that a MonoBehaviour is inactive and coroutines are not available.

      The interesting thing is that GraphOwner’s disableAction does not help here because GraphOwner.OnDestroy() invokes StopBehaviour() in any case.

      I think it would be more explicit to have some ActionTask.OnGraphDestroy() called instead of OnStop() on graph destruction…

      What do you think?

       

      #13270
      Gavalakis
      Keymaster

        Hey,

        hmm. Are you starting the couroutine using the StartCoroutine method of Task? I am asking because the implementation of that method starts a coroutine using the MonoManager (singleton) and as such, the fact that GraphOwner monobehaviour is destroyed (or will be) should not create any issues. Can you post the specific error you are getting please?

        Thanks!

        #13269
        anton petrov
        Participant

          I am calling into my code which is a MonoBehaviour component not directly related to a NodeCanvas logics. And this component starts a coroutine.

          In general, I would like my scene destruction was fast without unnecessary calls, events etc.

          Thank you.

          #13268
          Gavalakis
          Keymaster

            Hello again,
            I am sorry but I still do not really understand what the problem is. Can you please post the error and some code so that I understand?
            Please provide a bit more information.

            Thank you.

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