Space Plunder
Loading...
Searching...
No Matches
UBTD_DistanceVertical Class Reference

A decorator node that evaluates if the vertical distance between the AI agent and a target actor or location is above a certain threshold. More...

#include <BTD_DistanceVertical.h>

Inheritance diagram for UBTD_DistanceVertical:

Public Member Functions

 UBTD_DistanceVertical ()
 

Protected Member Functions

virtual FString GetStaticDescription () const override
 
virtual bool CalculateRawConditionValue (UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) const override
 

Protected Attributes

FBlackboardKeySelector TargetActor
 
float MinHeightDifference = 50.0f
 

Detailed Description

A decorator node that evaluates if the vertical distance between the AI agent and a target actor or location is above a certain threshold.

This decorator node is used to check if the vertical distance between the AI agent and a target actor or location is above a specified threshold. It inherits from the UBTDecorator_BlackboardBase class, which provides functionality for accessing and modifying blackboard values.

Constructor & Destructor Documentation

◆ UBTD_DistanceVertical()

UBTD_DistanceVertical::UBTD_DistanceVertical ( )
14{
15 NodeName = TEXT("Check Vertical Distance");
16}

Member Function Documentation

◆ CalculateRawConditionValue()

bool UBTD_DistanceVertical::CalculateRawConditionValue ( UBehaviorTreeComponent & OwnerComp,
uint8 * NodeMemory ) const
overrideprotectedvirtual
41{
42 TRACE_CPUPROFILER_EVENT_SCOPE(UBTD_DistanceVertical::CalculateRawConditionValue);
43 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Behaviors);
44 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Decorators);
45 if(OwnerComp.GetAIOwner() == nullptr || OwnerComp.GetAIOwner()->GetPawn() == nullptr){return false;}
46 const FVector ActorLocation = OwnerComp.GetAIOwner()->GetPawn()->GetActorLocation();
47 const UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent();
48 if(BlackboardComp != nullptr)
49 {
50 FVector TargetLocation;
51 //- Try Get key as an Actor //
52 const AActor* ActorObject = Cast<AActor>(BlackboardComp->GetValueAsObject(TargetActor.SelectedKeyName));
53 if(ActorObject != nullptr)
54 {
55 TargetLocation = ActorObject->GetActorLocation();
56 }
57 //- Get key as a Vector //
58 else
59 {
60 TargetLocation = BlackboardComp->GetValueAsVector(TargetActor.SelectedKeyName);
61 }
62 const float HeightDifference = ActorLocation.Z - TargetLocation.Z;
63 return (HeightDifference >= MinHeightDifference);
64 }
65 return false;
66}
float MinHeightDifference
Definition BTD_DistanceVertical.h:36
FBlackboardKeySelector TargetActor
Definition BTD_DistanceVertical.h:33
virtual bool CalculateRawConditionValue(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) const override
Definition BTD_DistanceVertical.cpp:40

◆ GetStaticDescription()

FString UBTD_DistanceVertical::GetStaticDescription ( ) const
overrideprotectedvirtual
19{
20 FString Description;// = Super::GetStaticDescription();
21 Description += FString::Printf(TEXT("\nMin Height Difference: %i"), FMath::RoundToInt(MinHeightDifference));
22 if (TargetActor.SelectedKeyName.IsValid())
23 {
24 Description += FString::Printf(TEXT("\nTarget Actor: %s"), *TargetActor.SelectedKeyName.ToString());
25 }
26 else
27 {
28 Description += TEXT("\nTarget Actor: None");
29 }
30 return Description;
31}

Member Data Documentation

◆ MinHeightDifference

float UBTD_DistanceVertical::MinHeightDifference = 50.0f
protected

◆ TargetActor

FBlackboardKeySelector UBTD_DistanceVertical::TargetActor
protected

The documentation for this class was generated from the following files: