Cannot implement "GenericTeamAgentInterface"

I’m trying to implement the TeamID variable for my character class so that the AIPerception stuff can detect the teams following this tutorial AI Perception in Unreal Engine 4 – How to Setup – Programming Tutorials

However when I try to add the interface the compiler asks me to implement every single function and stuff out of the generated file and gives me the linking errors:

Determining max actions to execute in parallel (8 physical cores, 8 logical cores)
Building 4 actions with 4 processes...
  [1/4] Compile BaseCharacter.gen.cpp
  [2/4] Compile BaseCharacter.cpp
  [3/4] Link (lld) libUnrealEditor-FLife2.so
  ld.lld: error: undefined symbol: Z_Construct_UClass_UGenericTeamAgentInterface_NoRegister()
  >>> referenced by BaseCharacter.gen.cpp
  >>>               /media/manjaro/AFiles/WorkCopies/FLife2-UE/FLife2/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Development/FLife2/BaseCharacter.gen.cpp.o:(Z_Construct_UClass_ABaseCharacter_Statics::InterfaceParams)
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process "bash '-c', 'Engine/Build/BatchFiles/Linux/Build.sh FLife2Editor Linux Development /media/manjaro/AFiles/WorkCopies/FLife2-UE/FLife2/FLife2.uproject -waitmutex'" terminated with exit code: 6.

BaseCharacter.h :

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "UObject/Interface.h"
#include "GenericTeamAgentInterface.h"
#include "BaseCharacter.generated.h"



UCLASS()
class FLIFE2_API ABaseCharacter : public ACharacter, public IGenericTeamAgentInterface
{
	GENERATED_BODY()


//----------------------------------------------------------------------//
// IGenericTeamAgentInterface
//----------------------------------------------------------------------//
private:
	FGenericTeamId TeamID;
public:
	virtual void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
	virtual FGenericTeamId GetGenericTeamId() const override { return TeamID; }
	virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) const;


};

BaseCharacter.cpp :

#include "BaseCharacter.h"



ETeamAttitude::Type ABaseCharacter::GetTeamAttitudeTowards(const AActor& Other) const
{
	return ETeamAttitude::Neutral;
}


void ABaseCharacter::SetGenericTeamId(const FGenericTeamId& NewTeamID)
{
	if (TeamID != NewTeamID)
	{
		TeamID = NewTeamID;
		// @todo notify perception system that a controller changed team ID
	}
}

Please any help would be appreciated! I’m really at a loss and I can’t find anyone with a similar issue.

Hi, did you include “AIModule” in your project dependencies? And by the way, AFAIK you don’t need to implement “GetTeamAttitudeTowards”, I at least didn’t (and it may not be a good idea to just return neutral there for everything…)

O ■■■■ that actually worked! Thanks alot dude!
Yea those functions were only there because It was asking me to implement everything. Kinda a confusing error.

That worked! Thanks alot!

How to do it?

In your game’s Build.cs file, you need to add AIModule in your PublicDependencyModuleNames

2 Likes