x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

error:LNK2001 within UBTService class

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) HellskriegCpp C:\Users\Erik\Desktop\Hellskrieg\HellskriegCpp\Intermediate\ProjectFiles\HellskriegCpp.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) HellskriegCpp C:\Users\Erik\Desktop\Hellskrieg\HellskriegCpp\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) HellskriegCpp C:\Users\Erik\Desktop\Hellskrieg\HellskriegCpp\Intermediate\ProjectFiles\HellskriegCpp.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 "HellskriegCpp.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. Erik

Product Version: UE 4.13
Tags:
more ▼

asked Oct 21 '16 at 01:32 PM in Bug Reports

avatar image

erik321123
403 17 15 31

avatar image ImVawx ♦♦ STAFF Oct 21 '16 at 05:17 PM

Hey erik321123,

Can you show me how you are using the BTService in your code?

Thanks.

avatar image erik321123 Oct 21 '16 at 07:40 PM

I have edited my original post, I am trying to use this via a behavior tre, however I haven't place this in the behaviour treesince it won't compile

avatar image ImVawx ♦♦ STAFF Oct 21 '16 at 07:46 PM

In your .Build.cs file, have you added "AIModule" to the "PublicDependencyModuleNames.AddRange"? Like:

 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule" });
avatar image erik321123 Oct 21 '16 at 07:49 PM

Yes I have

 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "AIModule" });

I also now can confirm that the name of the class is not the problem since I have tried to add another BTService class which gives the same error

avatar image erik321123 Oct 21 '16 at 08:02 PM

I will have a look in the shooter example from Epic since I know it has some c++ in the behavior tree. I hope that I can find the problem...

avatar image erik321123 Oct 24 '16 at 04:08 PM

It has no c+ BTServices...

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hey erik321123,

Sorry for the delay.

Can you update your Game.Build.cs file to this:

 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule", "GameplayTasks" });

Then, recompile the project. This fixed the issue on my end.

more ▼

answered Oct 25 '16 at 09:18 PM

avatar image

ImVawx ♦♦ STAFF
6.7k 114 17 127

avatar image erik321123 Oct 26 '16 at 02:46 PM

after chaninging it to this:

 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule", "GameplayTasks", "HeadMountedDisplay"});

It worked

Thank you very much!

avatar image ImVawx ♦♦ STAFF Oct 26 '16 at 02:56 PM

Hey erik321123,

Glad that helped.

Thank you for submitting a bug report, however at this time we believe that the issue you are describing is not actually a bug with the Unreal Engine, and so we are not able to take any further action on this. If you still believe this may be a bug, please provide steps for us to reproduce the issue, and we will continue our investigation.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question