UBTService

Behavior Tree service nodes is designed to perform "background" tasks that update AI's knowledge.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

AIModule

Header

/Engine/Source/Runtime/AIModule/Classes/BehaviorTree/BTService.h

Include

#include "BehaviorTree/BTService.h"

Syntax

class UBTService : public UBTAuxiliaryNode

Remarks

Behavior Tree service nodes is designed to perform "background" tasks that update AI's knowledge.

Services are being executed when underlying branch of behavior tree becomes active, but unlike tasks they don't return any results and can't directly affect execution flow.

Usually they perform periodical checks (see TickNode) and often store results in blackboard. If any decorator node below requires results of check beforehand, use OnSearchStart function. Keep in mind that any checks performed there have to be instantaneous!

Other typical use case is creating a marker when specific branch is being executed (see OnBecomeRelevant, OnCeaseRelevant), by setting a flag in blackboard.

Because some of them can be instanced for specific AI, following virtual functions are not marked as const:

If your node is not being instanced (default behavior), DO NOT change any properties of object within those functions! Template nodes are shared across all behavior tree components using the same tree asset and must store their runtime properties in provided NodeMemory block (allocation size determined by GetInstanceMemorySize() )

Variables

Name Description

Protected variable

uint32: 1

 

bCallTickOnSearchStart

Call Tick event when task search enters this node (SearchStart will be called as well)

Protected variable

uint32: 1

 

bNotifyOnSearch

If set, service will be notified about search entering underlying branch

Protected variable

uint32: 1

 

bRestartTimerOnEachActivation

If set, next tick time will be always reset to service's interval when node is activated

Protected variable

float

 

Interval

Defines time span between subsequent ticks of the service

Protected variable

float

 

RandomDeviation

Adds random range to service's Interval

Constructors

Name Description

Public function

UBTService

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Protected function Virtual Const

FString

 

GetStaticServiceDescription()

Gets the description for our service.

Protected function Const

FString

 

GetStaticTickIntervalDescription()

Gets the description of our tick interval.

Public function

void

 

NotifyParentActivation

(
    FBehaviorTreeSearchData& SearchDat...
)

Protected function Virtual

void

 

OnSearchStart

(
    FBehaviorTreeSearchData& SearchDat...
)

Called when search enters underlying branch this function should be considered as const (don't modify state of object) if node is not instanced!

Protected function

void

 

ScheduleNextTick

(
    uint8* NodeMemory
)

Set next tick time

Overridden from UBTAuxiliaryNode

Name Description

Protected function Virtual

void

 

TickNode

(
    UBehaviorTreeComponent& OwnerComp,
    uint8* NodeMemory,
    float DeltaSeconds
)

Update next tick interval this function should be considered as const (don't modify state of object) if node is not instanced!

Overridden from UBTNode

Name Description

Protected function Virtual Const

FName

 

GetNodeIconName()

Get the name of the icon used to display this node in the editor

Public function Virtual Const

FString

 

GetStaticDescription()

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback