AI Decorator 'Is At Location' Abort

In Behavior-Tree I need ‘Is At Location’ abort, so that If the AI is too close to the Player, the sequence will be aborted by the decorator and Immediately continue to the Next Sequence.

The problem is that I can’t find the FlowControl/Abort settings in the ‘Is At Location’ Decorator…any help?

IsAtLocation doesn’t observe any Blackboard values that’s why it doesn’t have an Observer Abort.

I’m not seeing the whole picture of what you wanted to do, but if I wanted to abort the current task and move to the next one if the AI is too close to the Player, I would do something like this:

  1. Create a new Decorator IsCloseEnoughFromPlayer to check if an AI is within the AcceptableRadius:

    Variables:

  • AcceptableRadius (float), InstanceEditable: true
  • PlayerPawnToFollow (Blackboard Key Selector), InstanceEditable: true

  1. My BT example for moving to the next Task when Player gets too close to the AI. (Note: Wait task is on the left of the Idle task just to make it less priority than the Wait task). Also, my IsCloseEnoughFromPlayer decorator’s Observer aborts value is set to Lower Priority.

What happens above is, if the BT is on the Idle task, as soon as the player gets too close to the AI, the Idle task will abort event if it didn’t finish running and move to the higher priority node (left node).

1 Like

I’m amazed this worked but I made a C++ subclass of IsAtLocation and this subclass is able to interrupt. I’m pretty sure it means it’s going to keep checking constantly though.

#pragma once

#include "BehaviorTree/Decorators/BTDecorator_IsAtLocation.h"

#include "RDBaseBTDecorator_RDIsAtLocation.generated.h"

/**
 * A version of IsAtLocation that allows interruption of children.
 * This will end up reevaluating often
 */
UCLASS()
class RDBASEFRAMEWORK_API URDBaseBTDecorator_RDIsAtLocation : public UBTDecorator_IsAtLocation
{
	GENERATED_BODY()

	URDBaseBTDecorator_RDIsAtLocation()
		: Super()
	{
		bAllowAbortLowerPri = true;
		bAllowAbortNone = true;
		bAllowAbortChildNodes = true;
	}
};