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?