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…
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?
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.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.