Download

AI Perception Infinite FVector Value & GetTeamAttitudeTowards(const AActor& Other)

Hey everyone,

I started to play around with AI Perception today and I got some weird problems.
The first one, is that when ever OnPerceptionUpdated() have been called in the FActorPerceptionBlueprintInfo.LastSensedStimuli array have objects with infinite Age, and Location values, for AISense components even if they didn’t picked up anything yet.

Element with a good value:


Element with a bad value:

Array after the AI registered the Hearing too:

My second issue is, that GetTeamAttitudeTowards() method not really working. In the PlayerController header, I implemented the IGenericTeamAgentInterface and the following variables and method:



private:
FGenericTeamId TeamId;

virtual FGenericTeamId GetGenericTeamId() const override;


in the .cpp I set the variable and the implemented method



FGenericTeamId AHPlayerController::GetGenericTeamId() const
{
     return TeamId;
}


In the AI Controller I added the methods to the header:



// Override the attitude toward the players
ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) const override;


in the .cpp



ETeamAttitude::Type AHEntityControllerBase::GetTeamAttitudeTowards(const AActor& Other) const
{
     const APawn* OtherPawn = Cast<APawn>(&Other);
     if (OtherPawn)
     {
        const IGenericTeamAgentInterface* TeamInterface = Cast<IGenericTeamAgentInterface>(OtherPawn->GetController());
        if (TeamInterface && TeamInterface->GetGenericTeamId() == FGenericTeamId(0))
        {
            return ETeamAttitude::Hostile;
        }
        UE_LOG(LogTemp, Warning, TEXT("TeamInterface is null or ID is not 0"));
    }
    return Super::GetTeamAttitudeTowards(*OtherPawn->GetController());
}


The result is that the AISense_Sight only detects the player if I tick the Neutral box, and the AISense_Hearing only works if I tick the Friendly box.
Any clue? Thanks in advance!