So I know that there are a couple of tutorials coming up on how to use the new AI Perception System. I can’t wait to really dig in and start using it, but seeing as those aren’t out yet (any idea when one will be up?) I was wondering if anyone knows how to do a simple setup for it to do some simple sensing. This is what I’ve gotten so far but I seem to be missing something:
First inside of my controller (Constructor) I setup my function that will do stuff when I see something:
PerceptionComponent->OnPerceptionUpdated.AddDynamic(this, &AAIControllerUnit::SenseStuff);
Next also inside of my controller (OnPossess) I configure my sight sense:
// Setup the perception component
sightConfig->SightRadius = possessedUnit->sightRange;
sightConfig->LoseSightRadius = (possessedUnit->sightRange + 20.0f);
sightConfig->PeripheralVisionAngleDegrees = 360.0f;
PerceptionComponent->ConfigureSense(*sightConfig);
Next I register my pawn as a stimuli source so that I can detect it (also in OnPossess):
// Setup the controlled pawn as a stiumuli source for the Perception System
UAIPerceptionSystem::RegisterPerceptionStimuliSource(this, sightConfig->GetSenseImplementation(), GetControlledPawn());
Now in the Tick() of the controller i do this:
PerceptionComponent->RequestStimuliListenerUpdate();
Finally my sense stuff function inside of the controller:
void AAIControllerUnit::SenseStuff(TArray<AActor*> testActors)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "I see you!");
}
I think i’m close to figuring it out but i’m missing something key (or maybe I should just wait for a tutorial haha). Essentially the SenseStuff function is never getting called when two of my units that are using this get close to each other.
Thanks in advance!
-Chris