How to decipher FAIStimulus.Type?

Hi,

in my OnTargetPerceptionUpdate, within my AI controller, I want to tell what type of stimulus has triggered the update.
The function is triggered with an “FAIStimulus” in its argument; and FAIStimulus includes the “Type” variable that seems exactly what I need (check FAIStimulus | Unreal Engine Documentation).

My issue is that this variable is of type “FAISenseID”, that in turn is a type-defined as:

typedef FAINamedID<FAISenseCounter> FAISenseID;

Trying to track that variable down as if it was an int (looks like FAINamedId is a structure to give a unique numerical identifier to… things), and getting 0 and 1s as results:

FString stimulustype = FString::FromInt(Stimulus.Type);
	UE_LOG(LogTemp, Warning, TEXT("Stimuli type is : %s"), *stimulustype);

Does anybody know how to actually parse these?? I’d expect something like an enum with correspondences to the various possible stimuli types, but couldn’t find anything.

f

1 Like

Issue solve. You can get “ID” for each sense asking your sense config class. So to know whether your character has seen or heard something, you have to store your sense IDs and then match against those IDs:

    FAISenseID sightid = SightConfig->GetSenseID();
	FAISenseID hearid = HearingConfig->GetSenseID();

	if (Stimulus.Type == sightid)
		UE_LOG(LogTemp, Warning, TEXT("I SAW YOU!"));
	else if (Stimulus.Type == hearid)
		UE_LOG(LogTemp, Warning, TEXT("I HEARD YOU!"));

cheers

f

4 Likes

This is very helpful! Thank you.

I was confused how to get the SightConfig itself from an ID. I dug through the source and found there is a static template member function where you can pass in the sense class and get the id:

e.g. for sight:

UAISense::GetSenseID<UAISense_Sight>()
5 Likes

Man can’t thank you enough. The unreal documentation is so bad, took me forever to find this. Thanks a lot

1 Like