RealDocs

AAIController::GetGenericTeamId

function AIModule Since 4.12
#include "AIController.h"
Access: public Specifiers: virtualconstoverride

Description

Returns the team ID assigned to this AI controller. Used by AI Perception and EQS team-attitude queries to determine friend/foe relationships.

Caveats & Gotchas

  • Returns `FGenericTeamId::NoTeam` (255) if `SetGenericTeamId` was never called. Perception components treat NoTeam as neutral by default, so uninitialized controllers may not trigger expected hostile detections.
  • This is an inline function returning a private member — it cannot be overridden further without also storing your own field, since `TeamID` is private to `AAIController`.

Signature

virtual FGenericTeamId GetGenericTeamId() const override { return TeamID; }

Return Type

FGenericTeamId

Example

Check team before attacking C++
bool AMyAIController::IsFriendly(AActor* Other) const
{
	if (IGenericTeamAgentInterface* OtherAgent = Cast<IGenericTeamAgentInterface>(Other))
	{
		return FGenericTeamId::GetAttitude(GetGenericTeamId(), OtherAgent->GetGenericTeamId())
			== ETeamAttitude::Friendly;
	}
	return false;
}

Version History

Introduced in: 4.12

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.