Hello!
I have an already working game with BT,services,tasks.
What i want to do is replicate these services,tasks,decorators in C++ so i can make them more customised and eventually want to use 3rd party libraries to process data in service(s) so i can try out myself with machine learning,neural networks.
So i decided to begin with simple stuff however i managed to hit a wall after looking for possible solutions to my problem but couldn’t figure out how to solve it based on the answers.
Anyway i just want to make a new task node in C++ that i could use in the editor as a building block.
Here is the header file:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "BehaviorTree/BTTaskNode.h"
#include "MyBTTaskNodeTest1.generated.h"
UCLASS()
class MYPROJECT_API UMyBTTaskNodeTest : public UBTTaskNode
{
GENERATED_BODY()
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
};
Here i read some solutions suggested to include the myproject_api part,then there was one where the generated_body() part was something else so it had to be changed to the one i am already using.
I started out the way it is now so that can’t be the problem afaik.
And the .cpp file:
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyProject.h"
#include "MyBTTaskNodeTest.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "Runtime/AIModule/Classes/AIController.h"
#include "Runtime/AIModule/Classes/Blueprint/AIBlueprintHelperLibrary.h"
EBTNodeResult::Type UMyBTTaskNodeTest::ExecuteTask(class UBehaviorTreeComponent & OwnerComp, uint8 * NodeMemory)
{
//Get controller of the owner component
AAIController* AICon = Cast<AAIController>(OwnerComp.GetAIOwner());
//check if it's valid
if (AICon == nullptr)
{
return EBTNodeResult::Failed;
}
//check if the pawn is valid
if (AICon->GetPawn() == nullptr)
{
return EBTNodeResult::Failed;
}
//If both valid get the blackboard component of the pawn
AActor* Pawn = nullptr;
UBlackboardComponent* BlackboardComp = nullptr;
if (AICon && (AICon->GetPawn()) )
{
Pawn = AICon->GetPawn();
BlackboardComp = UAIBlueprintHelperLibrary::GetBlackboard(Pawn);
}
//If the blackboard component is valid print out a text
if (BlackboardComp)
{
UE_LOG(LogTemp, Warning, TEXT("BlackBoardComponent successfully found!"));
return EBTNodeResult::Succeeded;
}
return EBTNodeResult::Type();
}
When i compile in VS it gives 0 errors or warnings and everything goes smooth!
However when i try to compile in the Unreal Editor i get the following errors:
CompilerResultsLog:Error: Error MyBTTaskNodeTest.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl IGameplayTaskOwnerInterface::OnGameplayTaskActivated(class UGameplayTask &)” (?OnGameplayTaskActivated@IGameplayTaskOwnerInterface@@UEAAXAEAVUGameplayTask@@@Z)
CompilerResultsLog:Error: Error MyProject.generated.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl IGameplayTaskOwnerInterface::OnGameplayTaskActivated(class UGameplayTask &)” (?OnGameplayTaskActivated@IGameplayTaskOwnerInterface@@UEAAXAEAVUGameplayTask@@@Z)
CompilerResultsLog:Error: Error C:\UE4_Projects\MyProject\Binaries\Win64\UE4Editor-MyProject-4703.dll : fatal error LNK1120: 1 unresolved externals
I got similar errors before in VS because i didn’t include a header file but eventually solved them.However this time i don’t know what to do.
So my questions:
-
What to do?I see what the error is but this is the first time i run
into linker issues since i learned
the basics of C++ with gcc with
simple classes. So i am not familiar with troubleshooting especially in this case where it works in one enviroment but fails in another. -
What can i do in the future to avoid
problems like these? -
What would be the best
format,structure for my goal
with deep learning?Is it good enough
to use a service,process data in it
then produce an output and based on that output run a task?
Also if there are suggestions regarding my coding feel free to tell them.(format,etc…).