How to use UAIPerceptionComponent->GetPerceivedActors?

UAIPerceptionComponent::GetPerceivedActors(TSubclassOf<UAISense> SenseToUse, TArray<AActor*>& OutActors) const

I want the Sight to be used, but my IDE is not allowing me to create a new one UAISense_Sight, and I don’t know how to pass the SenseToUse parameter properly.

Does anyone know how to setup UAISense properly?

GetPerceivedActors(UAISense_Sight::StaticClass(), OutActors)

2 Likes

Thanks!!!

2 Likes

What it’s looking for there is an actual UClass that is at least a UAISense … so you can just specify the StaticClass() of whatever class you want to use that is a subclass of UAISense. StaticClass() is a static function (so you can call it in the class itself, rather than an instance of that class) that returns the class it is.

2 Likes

If your component’s dominant sense is sight, just do a
PerceptionComp->GetDominantSense()

2 Likes