The problem I'm having is my AI I constructed will not recognize neither the player nor the Vector of the player.

the above image is the behavior tree simulating and by the bottom right all the values are zeroed out or set to None
. I also have blackboard variables for the behavior tree as well.
.h
.cpp
Most of this code is from the ShooterGame code for testing and template usage.
Any ideas??
the above image is the behavior tree simulating and by the bottom right all the values are zeroed out or set to None

.h
Code:
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #pragma once #include "GameFramework/AIController.h" #include "CorruptAI.generated.h" /** * */ UCLASS() class ACorruptAI : public AAIController { GENERATED_UCLASS_BODY() UPROPERTY(transient) TSubobjectPtr<class UBlackboardComponent> BlackboardComp; UPROPERTY(transient) TSubobjectPtr<class UBehaviorTreeComponent> BehaviorComp; virtual void Possess(class APawn* InPawn); virtual void Tick(float DeltaTime); void SetEnemy(class APawn* InPawn); class ASideScrollerConceptCharacter *GetEnemy() const; UFUNCTION(BlueprintCallable, Category = Behavior) void SearchForEnemy(); protected: int32 EnemyKeyID; int32 EnemyLocationID; };
.cpp
Code:
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #include "SideScrollerConcept.h" #include "CorruptAI.h" #include "CorruptBot.h" #include "SideScrollerConceptCharacter.h" ACorruptAI::ACorruptAI(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { BlackboardComp = PCIP.CreateDefaultSubobject<UBlackboardComponent>(this, TEXT("BlackBoardComp")); BehaviorComp = PCIP.CreateDefaultSubobject<UBehaviorTreeComponent>(this, TEXT("BehaviorComp")); } void ACorruptAI::Possess(class APawn* InPawn) { Super::Possess(InPawn); ACorruptBot* Bot = Cast<ACorruptBot>(InPawn); if (Bot && Bot->BotBehavior) { BlackboardComp->InitializeBlackboard(Bot->BotBehavior->BlackboardAsset); EnemyKeyID = BlackboardComp->GetKeyID("Enemy"); EnemyLocationID = BlackboardComp->GetKeyID("Destination"); BehaviorComp->StartTree(Bot->BotBehavior); } } void ACorruptAI::Tick(float DeltaTime) { } void ACorruptAI::SearchForEnemy() { APawn* MyBot = GetPawn(); if (MyBot == NULL) { return; } const FVector MyLoc = MyBot->GetActorLocation(); float BestDistSq = MAX_FLT; ASideScrollerConceptCharacter* BestPawn = NULL; for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It) { ASideScrollerConceptCharacter* TestPawn = Cast<ASideScrollerConceptCharacter>(*It); if (TestPawn) { const float DistSq = (TestPawn->GetActorLocation() - MyLoc).SizeSquared(); if (DistSq < BestDistSq) { BestDistSq = DistSq; BestPawn = TestPawn; } } } if (BestPawn) { SetEnemy(BestPawn); } } void ACorruptAI::SetEnemy(class APawn* InPawn) { BlackboardComp->SetValueAsObject(EnemyKeyID, InPawn); BlackboardComp->SetValueAsVector(EnemyLocationID, InPawn->GetActorLocation()); SetFocus(InPawn); } class ASideScrollerConceptCharacter* ACorruptAI::GetEnemy() const { if (BlackboardComp) { return Cast<ASideScrollerConceptCharacter>(BlackboardComp->GetValueAsObject(EnemyKeyID)); } return NULL; }
Any ideas??
Comment