Constructing Task nodes

Task nodes are like function blocks. Each Task node you construct will allow you to bundle up some Blueprint code for execution when certain conditions in your Behavior Tree are met.

Tasks have three distinct events: Receive Tick (with AI version), Receive Execute (AI), and Receive Abort (AI). You can respond to any of these three events in the Task's Blueprint. Usually, you should respond to the Receive Execute (AI version) of the Task.

Getting ready

To create a Task node, you should already have a Behavior Tree ready and attached to an appropriate AI Controller and Blueprinted Character (see previous recipe).

How to do it…

  1. To construct a Task node with an executable Blueprint code inside it, you must select New Task from the menu bar from our Behavior Tree Blueprint editor. From the drop-down menu that appears, select to base your New Task on BTTask_BlueprintBase.
    How to do it…

    Tip

    Unlike Behavior Tree or Blackboard creation, there isn't a way to create a New Task directly from the Content Browser.

  2. Double-click and open the Behavior Tree task that you've just created to edit it. Override any of the available events (listed in the Functions subheading under the My Blueprint tab):
    1. Receive Tick AI: The AI version of the Tick event for the Behavior Tree Task. You should override this function when you need your task to Tick with the actor that contains it. Do not override this function if you only want your task to execute when it is called by the Behavior Tree (not when the game engine ticks).
    2. Receive Execute AI: The main function that you want to override. Receive Execute AI allows you to run some Blueprint code whenever the Task node is invoked from the Behavior Tree diagram.
    3. Receive Abort AI: An abortion on a Behavior Tree task is called when the task is being aborted (by a FinishAbort() node call from the Blueprints diagram).

      Tip

      There are non-AI versions of the preceding functions, which have just differing arguments: In the *AI version, the owner object is cast as a Pawn, and there is an Owner Controller passed along to the event call.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.117.253