unity行为树的事件函数 简单测试

// OnAwake is called once when the behavior tree is enabled. Think of it as a constructor

public virtual void OnAwake();
// OnStart is called immediately before execution. It is used to setup any variables that need to be reset from the previous run
public virtual void OnStart();
// OnUpdate runs the actual task
public virtual TaskStatus OnUpdate();
// OnEnd is called after execution on a success or failure. 
public virtual void OnEnd();
// OnPause is called when the behavior is paused and resumed
public virtual void OnPause(bool paused);

第一帧:

          两个任务的OnAwake均执行了--------OnAwake是行为树Enable==true时执行

          第一个任务的OnStart执行--------------OnStar是进入任务后,执行第一次OnUpdate前执行

          第一个任务的OnUpdate执行,

第二帧:

          第一个任务OnUpdate执行一遍

第三帧:

          第一个任务OnUpdate执行一遍,返回任务成功

          接着执行了第一个任务的OnEnd

          然后开始第二个任务的OnStart()    ,OnAwake已经执行了

第四帧

        第二个任务的OnUpdate执行

第五帧:

       第二个任务的OnUpdate执行,任务成功

       接着执行了第二个任务的OnEnd

猜你喜欢

转载自blog.csdn.net/qq_38806355/article/details/82943167