When do OnEnable/OnDisable get called in a ConditionTask?

NodeCanvas Forums Support When do OnEnable/OnDisable get called in a ConditionTask?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13182
    step
    Participant

    Hey everybody,

    i am trying to create a bunch on custom ConditionTasks to integrate another library into NodeCanvas, which is sending out System.Actions as events. So far i am registering to the events via OnInit override and YieldReturn(true) when an event is incoming – which seems to work fine.

    Now i am looking for a proper place to unregister the eventhandler again and found virtual OnEnable/OnDisable methods in the ConditionTask source – which are the usual place to register/unregister System.Actions in standard MonoBehaviours, but those methods seem to never get called.

    So, when are those methods being called? Is there a better place to unregister already registered actions?

    #13187
    Gavalakis
    Keymaster

    Hello,

    The OnEnable and OnDisable callbacks of ConditionTasks are only called in the context of FSMs, since in FSM there exists a definite time that a condition can be considered as enabled/disabled (when parent state enters and exits respectively), but in the context of Behaviour Trees, a condition task does not have clear time at which it is considered enabled/disabled.
    Having said that, I am thinking of calling back OnEnable and OnDisable, once when the Behaviour Tree starts, and once when it ends respectively though.

    Will that work for you. Let me know what you think.
    Thanks!

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

    #13191
    step
    Participant

    Hi Gavalakis,

    that explains a lot! I thought it might be something along those lines so thanks for your detailed answer.
    Regarding calling OnEnable/OnDisable at start/end of the BT, I think that might perfecly for me and i also think it would generally be a good idea to have a chance to construct/destruct stuff in any Task. So if that doesn’t iterfere too much with anything else I’d say go for it!

    #13194
    Gavalakis
    Keymaster

    Hello again,

    You are very welcome and thanks for the follow up.
    Alright then 🙂 I will make OnEnable and OnDisable be called at the start and end of BehaviourTrees respective for the next small version update, hopefully soon!

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

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