End Task In A Script?

One way would be to have your active task check against your MonoBehaviour script to decide if it should continue. If it can't then it should return success or failure.
 
Should I use the NodeData.ExecutionStatus in monobehaviour so that I can stop a task from a behavior from running?
behaviorTree.FindTask<Sleep>().NodeData.ExecutionStatus = BehaviorDesigner.Runtime.Tasks.TaskStatus.Success;

It doesn't seem to stop the task if it is still running.
 
No, you don't want to set the execution status. Within your task you should return a task status of success or failure.

Code:
public TaskStatus OnUpdate()
{
   if (myMonoBehaviour.ShouldEndTask()) {
      return TaskStatus.Success;
   }
   return TaskStatus.Running;
 
Top