How do I use the AI Perception Teams?

Sure!

In the AIPerceptionComponent, when it is Registered, it casts the result of GetOwner*()* to AIController and sets it to the AIOwner property on the Component.

*AIOwner *is the target it uses to get FGenericTeamId for the **AIPerceptionComponent. **Without that reference, the component will always return FGenericTeamId::NoTeam.



FGenericTeamId UAIPerceptionComponent::GetTeamIdentifier() const
{
    return AIOwner ? FGenericTeamId::GetTeamIdentifier(AIOwner) : FGenericTeamId::NoTeam;
}


It is also used to set the IsHostile property on Structures passed up to blueprint:



PerceptualInfo->bIsHostile = AIOwner != NULL && FGenericTeamId::GetAttitude(AIOwner, SourcedStimulus->Source) == ETeamAttitude::Hostile;


So, by attaching the AIPerceptionComponent to a pawn, it will always be FGenericTeamId::NoTeam, and will aways have Neutral Attitude. It is however still useful for detecting sources.

2 Likes