Onto the thankfully less meaty AI Controllers and Pawns.
There’s two key things to learn here:
A PerceptionComponent must be on an AIController to work. AIController already inherits from IGenericTeamAgentInterface, but the value it returns is private, both in Blueprint and C++, AND isn’t recognized in the Reflection System. Huh…
An **AIPerceptionStimuliSource **needs to be on the actual Source Actor, which must implement the IGenericTeamAgentInterface in order for the Attitude Solver to return an Attitude that isn’t just Neutral.
So to get this working fully, we’ll want to Implement the **IGenericTeamAgentInterface **on an **AAIController **child class, and on any AActor that will have an **AIPerceptionStimuliSource, **returning what we want instead:
UCLASS()
class AMyAIController : public AAIController
{
GENERATED_BODY()
public:
UPROPERTY(Category = "Artificial Intelligence", BlueprintReadWrite, EditAnywhere)
EGameTeam AITeamID;
public:/**IGenericTeamAgentInterface*/
virtual void SetGenericTeamId(const FGenericTeamId& InTeamID) override;
virtual FGenericTeamId GetGenericTeamId() const override;
};
void AMyAIController::SetGenericTeamId(const FGenericTeamId & InTeamID)
{
AITeamID = (EGameTeam)InTeamID.GetId();
}
FGenericTeamId AMyAIController::GetGenericTeamId() const
{
return uint8(AITeamID);
}
The only change to the above code for a Regular **AActor **class, would be to add in “, public IGenericTeamAgentInterface” after “public AActor”
Now, we should be done. I’ve probably forgotten something, so let me know how you go!