Behavior Tree / AI Activation

I have some Behavior-Tree driven AI characters. The behavior tree is fairly simple and straightforward, the enemy character walks a patrol. Inputs from [FONT=Courier New]UPawnSensingComponent can raise their alert level, and if they become alerted, they start searching, if they find the player, they take one of several actions depending on various parameters. They might charge, stand and fire, or find cover.

Everything works fine, except if the enemy character is a certain distance from the player, they just stand there. I can see the enemy’s awareness increasing, and at a certain point, they will start doing some of the behavior in the tree (shooting at the character, looking around). I can see, in the debugger, that the behavior tree is running, but the controlled characters only seem to actually MOVE if they’re within a certain distance of the player.

Does anyone have any idea what may be causing this? I’ve tried playing with the various distances on the [FONT=Courier New]AIController and [FONT=Courier New]UPawnSensingComponent, but nothing seems to change this behavior.

Any suggestions or thoughts would be greatly appreciated.

Hello,
I just did a try and not sure it will help you but with the ai / bt quick start guide, the distance of aggro change when you modify the “radius” input of the multi sphere trace for objects in BT Service.
First trace in :

https://docs.unrealengine.com/latest/images/Engine/AI/BehaviorTrees/QuickStart/9/fullGraph.png

from https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/QuickStart/9/index.html

Thanks. Unfortunately, our tree isn’t really set up like that. In this case, the behavior tree runs for each character right from the level start. The BT Service doesn’t calculate aggro, each Character keeps track of its own aggro based on sensory input (onHearNoise(), onSeePawn()) and the BTService just grabs the value from the character and puts them on the blackboard.

Even when calm, the bots should be following their patrol route. Even though the behavior tree is running, they don’t walk or run unless the player is nearby.

Hi,

any idea on what the distance is where the AI doesnt react anymore?

This does sound a bit like the deactivation “issue” with particlesystems, which get automatically deactivated when no longer visible in the viewport; But i doubt that pawns have such a bound scale and get deactivated…?

Cheers,

The funny thing is, I haven’t noticed them deactivating, it seems to be just an activation problem. And it’s not even activation - I can see the Behavior Tree working, they just seem to ignore my MoveToward node (basically Move To, but the task returns true immediately rather than waiting for you to get to your destination)

Once they start moving, they seem to keep moving, but they don’t start moving until the player gets near. I’m guessing it’s about 2000 - 3000 world units away when they start moving, but I haven’t measured it.

Hmmm,

just tried with my own project and moved a pawn with his waypoints around 5000 units away, and he still patrolled (though i quickly checked by zooming out).

4.6.1 or 4.7?

And, how did you implement your own MoveTo Task (i understood you dont use the standard one)? I too got my own implementation using the AIMoveTo Node, and that one seems to work (for now).

Cheers,

Here is my Move Toward task. It’s essentially the same as the in-engine “Move To”, in fact, I started with the engine-code, and then removed the waiting stuff, and just return True immediately.

I thought everything was working fine until we started working on this really big hangar bay level, and I noticed when I would scope in on the distant bots, they’d just be standing there. The closer ones worked exactly as expected.



#include ".h"
#include "BTTask_MoveToward.h"
#include "BehaviorTree/BehaviorTree.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/Blackboard/BlackboardKeyType_Object.h"
#include "BehaviorTree/Blackboard/BlackboardKeyType_Vector.h"
#include "AIController.h"

// This class is identical to UBTTask_MoveTo except that it returns immediately rather than waiting until the character has reached the specified destination
//     This allows the behavior tree to continue executing and lets the character move smoothly without using a Simple Parallel node

UBTTask_MoveToward::UBTTask_MoveToward(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
    , AcceptableRadius(50.f)
    , bAllowStrafe(false)
{
    NodeName = "Move Toward";
    BlackboardKey.AddObjectFilter(this, AActor::StaticClass());
    BlackboardKey.AddVectorFilter(this);
}

EBTNodeResult::Type UBTTask_MoveToward::ExecuteTask(class UBehaviorTreeComponent* OwnerComp, uint8* NodeMemory)
{
    AAIController* MyController = OwnerComp ? Cast<AAIController>(OwnerComp->GetOwner()) : NULL;
    const UBlackboardComponent* MyBlackboard = OwnerComp->GetBlackboardComponent();

    EPathFollowingRequestResult::Type RequestResult = EPathFollowingRequestResult::Failed;

    if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass())
    {
        UObject* KeyValue = MyBlackboard->GetValueAsObject(BlackboardKey.GetSelectedKeyID());
        AActor* TargetActor = Cast<AActor>(KeyValue);
        if (TargetActor)
        {
            RequestResult = MyController->MoveToActor(TargetActor, AcceptableRadius, true, true, bAllowStrafe, FilterClass);
        }
    }
    else if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass())
    {
        const FVector TargetLocation = MyBlackboard->GetValueAsVector(BlackboardKey.GetSelectedKeyID());
        RequestResult = MyController->MoveToLocation(TargetLocation, AcceptableRadius, true, true, false, bAllowStrafe, FilterClass);
    }


    if (RequestResult == EPathFollowingRequestResult::Failed)
    {
        return EBTNodeResult::Failed;
    }

    return EBTNodeResult::Succeeded;

}

FString UBTTask_MoveToward::GetStaticDescription() const
{
    return "Moves the character toward the specified point, returning immediately.";
}

#if WITH_EDITOR

FName UBTTask_MoveToward::GetNodeIconName() const
{
    return FName("BTEditor.Graph.BTNode.Task.MoveTo.Icon");
}

#endif	// WITH_EDITOR


Have you tried debugging with the gameplay debugger component? press ’ when facing a given AI. You can see the state of the blackboard, behavior tree, EQS queries and Sense information(if using full perception system)

Yep, tree is firing, the destination is being set to a valid location, it’s just not walking to it. :frowning:

hello,if the tree is firing ,the destination is being set to a valid location,but the target to follow is none,when you tire debugging,maybe you didn’t pass the value to the Node in the bluepints of the’Argo check’

Did you ever figure this out? I am having this issue now myself. Everything should be working but the ai will not start moving until my player is within 3000 units.