Problem creating BT TaskNode Programmatically (C++)

Hi guys,

Hi having a weird problem, i like to create a TaskNode Programmatically for my AI Character and use it in the Behavior Tree. I dont have any problem creating it inside the editor with Blueprints, but i like to tests the same logic in C++.

I create a new class: Unreal Editor/File/Add code to project. Base class: UBTTaskNode.

Inmediatily without add any other code to this class, i try to Compile a run the code but i have a linking error:

Compiling with Mac SDK 10.9
Building UnrealHeaderTool…
Compiling with Mac SDK 10.9
Target is up to date.
Parsing headers for UE4TutorialEditor
LogTextLocalizationManager:Warning: The selected culture ‘es_ES’ is not available; falling back to ‘en’
Reflection code generation finished for UE4TutorialEditor and took 7,608
Performing 5 actions (max 2 parallel jobs)
[2/5] Compile SampleTaskNode.cpp
[1/5] Compile UE4Tutorial.generated.cpp
[3/5] Link UE4Editor-UE4Tutorial-Mac-Debug.dylib
Undefined symbols for architecture x86_64:
“UBTTaskNode::GetPrivateStaticClass(wchar_t const*)”, referenced from:
UBTTaskNode::StaticClass() in UE4Tutorial.generated.cpp.o
“UBTNode::GetWorld() const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::InitializeFromAsset(UBehaviorTree*)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::InitializeMemory(UBehaviorTreeComponent*, unsigned char*) const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::DescribeRuntimeValues(UBehaviorTreeComponent const*, unsigned char*, EBTDescriptionVerbosity::Type, TArray<FString, FDefaultAllocator>&) const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::GetInstanceMemorySize() const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::GetStaticDescription() const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“Z_Construct_UClass_UBTTaskNode()”, referenced from:
Z_Construct_UClass_USampleTaskNode() in UE4Tutorial.generated.cpp.o
“UBTNode::OnInstanceDestroyed(UBehaviorTreeComponent*)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::UsesBlueprint() const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::GetSpecialMemorySize() const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTNode::OnInstanceCreated(UBehaviorTreeComponent*)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTTaskNode::GetNodeIconName() const”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTTaskNode::TickTask(UBehaviorTreeComponent*, unsigned char*, float)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTTaskNode::ExecuteTask(UBehaviorTreeComponent*, unsigned char*)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“vtable for UBTNode”, referenced from:
UBTNode::~UBTNode() in SampleTaskNode.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
“UBTTaskNode::AbortTask(UBehaviorTreeComponent*, unsigned char*)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTTaskNode::OnMessage(UBehaviorTreeComponent*, unsigned char*, FName, int, bool)”, referenced from:
vtable for USampleTaskNode in SampleTaskNode.cpp.o
“UBTTaskNode::UBTTaskNode(FPostConstructInitializeProperties const&)”, referenced from:
USampleTaskNode::USampleTaskNode(FPostConstructInitializeProperties const&) in SampleTaskNode.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-------- End Detailed Actions Stats -----------------------------------------------------------
ERROR: UBT ERROR: Failed to produce item: /Users//Documents/Unreal Projects/UE4Tutorial/Binaries/Mac/UE4Editor-UE4Tutorial-Mac-Debug.dylib
Cumulative action seconds (4 processors): 0,00 building projects, 23,26 compiling, 0,00 creating app bundles, 0,00 generating debug info, 0,45 linking, 0,00 other
UBT execution time: 41,40 seconds
Command /Volumes/Macintosh_HD_2/UE4_443/Engine/Build/BatchFiles/Mac/Build.sh failed with exit code 2

Anyone can help me to find out what is the problem. What i doing wrong ??

Sorry for my bad english :S

Regards

You probably forgot to add “AIModule” as a dependency of whatever module you’ve put SampleTaskNode.cpp into.

Yes !! enlight_2014, i completely forget this detail :S, very thanks … Exactly, adding into PublicDependencyModuleNames.AddRange in MY_PROJECT.Build.cs the “AIModule” the problem was solved. Thanks for your answer.