Using periodic services

Services are nodes that contain Blueprint code to be executed periodically. Services are a lot like Tasks, but they do not have a FinishExecute() call at the end.

Getting ready

Adding Services to your Behavior Tree is essential for periodic checks of things such as if there are any new enemy units within range, or if your current target left focus. You can create your own Services. In this recipe, we'll assemble a Service that will check if the opponent you are following is still the closest within a visibility cone. If not, then the opponent changes.

There are four main events for a Service node (other than Tick):

  1. Receive Activation AI: Triggers when the Behavior Tree starts and the node is first activated.
  2. Receive Search Start AI: Triggers when the Behavior Tree enters the underlying branch.
  3. Receive Tick AI: Triggers each frame where the Service is invoked. The bulk of the work is performed here.
  4. Receive Deactivation AI: Triggers when the Behavior Tree closes and the node is deactivated.

How to do it…

  1. First, add a New Service to your Behavior Tree via the New Service button in the Behavior Tree Menu Bar:
    How to do it…
  2. Name your Service something that describes what it does, such as BehaviorTree_Service_CheckTargetStillClosest.
  3. Double-click on your Service to begin editing its Blueprint.
  4. In the editor, add a Receive Tick AI node, and perform any updates to the Blackboard that you need.

How it works…

Service nodes execute some Blueprint code at some regularly spaced time-intervals (with the option of deviation). Inside a Service node, you will usually update your Blackboard.

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

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