So I have been working on translating some blueprints into c++ and everything works fine untill I added a BTService called BTService_SenseCheck.
Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol “public: virtual void __cdecl IGameplayTaskOwnerInterface::OnGameplayTaskActivated(class UGameplayTask &)” (?OnGameplayTaskActivated@IGameplayTaskOwnerInterface@@UEAAXAEAVUGameplayTask@@@Z) C:\Users\Desktop\\Intermediate\ProjectFiles.generated.cpp.obj 1
Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol “public: virtual void __cdecl IGameplayTaskOwnerInterface::OnGameplayTaskActivated(class UGameplayTask &)” (?OnGameplayTaskActivated@IGameplayTaskOwnerInterface@@UEAAXAEAVUGameplayTask@@@Z) C:\Users\Desktop\\Intermediate\ProjectFiles\BTService_SenseCheck.cpp.obj 1
Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol “public: virtual void __cdecl IGameplayTaskOwnerInterface::OnGameplayTaskDeactivated(class UGameplayTask &)” (?OnGameplayTaskDeactivated@IGameplayTaskOwnerInterface@@UEAAXAEAVUGameplayTask@@@Z) C:\Users\Desktop\\Intermediate\ProjectFiles.generated.cpp.obj 1
If I completly comment out BTService_SenseCheck.h and BTService_SenseCheck.cpp I dont get this error anymore, however if I just comment out the custom code I get this error (an empty version of the class).
This is the code I am using, some lines have already been tried to be comment out.
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include ".h"
#include "BehaviorTree/BehaviorTree.h"
#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/Blackboard/BlackboardKeyAllTypes.h"
#include "Enemy_AI_Controller.h"
#include "HellskriegCppCharacter.h"
#include "UseFullFunctions.h"
#include "AISound.h"
#include "BTService_MemoryMarker.h"
#include "Kismet/KismetSystemLibrary.h"
#include "BTService_SenseCheck.h"
UBTService_SenseCheck::UBTService_SenseCheck()
{
bCreateNodeInstance = true;
SeesPlayer = false;
HearsPlayer = false;
}
void UBTService_SenseCheck::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
AEnemy_AI_Controller* EnemyController = Cast<AEnemy_AI_Controller>(OwnerComp.GetAIOwner());
//Make sure the cast succeeds
if (EnemyController)
{
//Get all players
TSubclassOf<AHellskriegCppCharacter> ClassToFind;
TArray<AActor*> Players;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ClassToFind, Players);
//Vision
for (int i = 0; i < Players.Num(); i++)
{
if (UseFullFunctions::AngleBetweenPoints(Players[i]->GetActorLocation() - EnemyController->GetPawn()->GetActorLocation(), EnemyController->GetPawn()->GetActorForwardVector()))
{
ACharacter* Character = Cast<ACharacter>(EnemyController->GetPawn());
if (Character)
{
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(Character->GetCapsuleComponent()->GetOwner());
FHitResult OutHit;
UKismetSystemLibrary::LineTraceSingle_NEW(GetWorld(), EnemyController->GetPawn()->GetActorLocation(), Character->GetActorLocation(), ETraceTypeQuery(ECC_Camera), false, ActorsToIgnore, EDrawDebugTrace::None, OutHit, true);
//Did the enemy see a friendly (other team)
ABasicFriendly* HitCharacter = Cast<ABasicFriendly>(OutHit.GetActor());
if (HitCharacter)
{
SeesPlayer = true;
OwnerComp.GetBlackboardComponent()->SetValueAsObject(FName("Target"), HitCharacter);
}
}
}
}
//END vision
//Hearing
TArray<AActor*> AISounds;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ClassToFind, AISounds);
float BestSoundDistance = 99999.f;
for (int i = 0; i < AISounds.Num(); i++)
{
AAISound* CurrentSound = Cast<AAISound>(AISounds[i]);
if(CurrentSound->Causer != EnemyController->GetOwner())
{
float Distance = (EnemyController->GetPawn()->GetActorLocation() - CurrentSound->GetActorLocation()).Size();
if (CurrentSound->Obvious)
{
Distance /= 2;
}
Distance /= CurrentSound->Strength;
if (Distance < BestSoundDistance)
{
BestSoundDistance = Distance;
if (Distance <= EnemyController->HearingRange)
{
AAI_MemoryMarker* MemoryMarker = GetWorld()->SpawnActor<AAI_MemoryMarker>(MemoryMarkerToSpawn->StaticClass(), CurrentSound->GetActorLocation(), FRotator(0.0f, 0.0f, 0.0f));
OwnerComp.GetBlackboardComponent()->SetValueAsObject(FName("MemoryMarker"), MemoryMarker);
}
}
}
}
//END Hearing
//Use gathered info
if (SeesPlayer || HearsPlayer)
{
OwnerComp.GetBlackboardComponent()->SetValueAsEnum(FName("State"), 2);
}
//TODO: Get highest thread and set it to target
}
}
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "BehaviorTree/BTService.h"
#include "BTService_SenseCheck.generated.h"
UCLASS()
class HELLSKRIEGCPP_API UBTService_SenseCheck : public UBTService
{
GENERATED_BODY()
public:
//Constructor
UBTService_SenseCheck();
//Tick
virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override;
private:
bool SeesPlayer;
bool HearsPlayer;
protected:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
AActor* MemoryMarkerToSpawn;
};
The problem seems to be within the egine, however I am not sure.