I have some questions regarding AI Perception

Hey, i have been testing out the AI Perception component for a project i’m working on but i have a couple of questions regarding how it works.

Firstly, is there a way to get more detailed information about a sense event?
In my code i have set up the perception event and a sight config which is working fine, i also have a function that is called when the perception is updated.

PerceptionComp->OnPerceptionUpdated.AddDynamic(this, &AMurdererController::AISense);

This is the actual code of that function.

void AMurdererController::AISense(TArray<AActor*> SensedActors)
{
	for (int i = 0; i < SensedActors.Num(); i++)
	{
		if (SensedActors[i]->ActorHasTag("Player"))
		{
			BlackboardComp->SetValue<UBlackboardKeyType_Bool>(CanSeeTargetKeyID, true);
		}
	}
}

I read somewhere that this function is called both when the player enters and leaves the view, is there some function or variable that you can check to see if the actor is leaving or entering the view?

And secondly, the AI i’m creating will be a humanoid with a skeletal mesh. I would like the AI’s sight to be from the AI’s head on the skeletal mesh, is this possible? I was thinking you could do this by having a socket on the AI’s head and place the perception component into that socket, would that work?

Cool, just what i wanted to know.
As for 4.8, is there a list of changes that have been made since 4.7 regarding the AI perception? I was looking at the forum post but cannot find anything particular.

To figure out if an actor is “visible” you need to get perception data regarding that actor, something along the following lines:

const FActorPerceptionInfo* Info = PerceptionComp->GetActorInfo(SensedActors[i]);
if (Info && Info->LastSensedStimuli.Num() > 0)
{
	// Info->LastSensedStimuli[Index].WasSuccessfullySensed() has information tou need
}

Regarding testing visibility from a specific point attaching component to a socket won’t work. You need to override GetActorEyesViewPoint in your pawn class and fill the out parameters to whatever you need.

In general I’d advice you to pick 4.8 up since it has a fair amount of improvements and bugfixes to AI perception.

Cheers,

–mieszko

There should be some information in the release notes.

Where is that? The only thing i can find is this forum post Unreal Engine 4.8 Preview - Announcements - Epic Developer Community Forums

I believe this is what you are looking for: Unreal Engine 4.8 Release Notes | Unreal Engine Documentation. Look for “AI perception” in here.