AIPerception and AIStimulus strength

Hi, I’m currently using the new detection system. Here is my blueprint :

The problem is my strength returned is always -1 (default value). Even if my blueprint works perfectly in game. I use this in my player blueprint :

I want to set behavior according to the distance and the strength of the stimulus so all my AI is related to this problem. Do not hesitate to ask me for more details but everything i have created is here. And all my components are correctly setuped.

Regards.

Up. Really need an answer for this please :frowning:

So I did a little testing on a fresh 4.10 project, and it is registering as a strength of 1.0 as long as you are in range of the AI. What I think is occurring in your example above: you are grabbing the last sensed stimuli at the index equal to the index of the actor sensed. This isn’t needed, as you are grabbing the last sensed stimuli of this actor, and do not need to use the actor’s index value from the perception. Try using index 0, or doing a for-each loop on the last sensed stimuli array, and then grab the strength and location.

A possible way to implement this would be to continuously add value while there is stimulus present, until a threshold has been breached, thus successfully “sensing” the actor. You could also adjust this value based on the distance to the target, which can be obtained by checking where the stimuli came from against where the AI is currently at. As far as I know, strength isn’t implemented via blueprints yet, so it will typically be 1.0 no matter what you do. I’ve tested different ranges, different loudness settings, and different perception settings to no avail. It always registers as 1.0 for the strength.

EDIT:

Here is my example for getting strength based on distance. In it, we have an AI Perception component setup for hearing, and with a range of 3000 units. To calculate the strength, from the actor itself (center of the AI actor), we get the actor’s location, subtract the vector from the vector provided as the stimulus origin, and grab the vector length. We subtract the length from our hearing distance (or from a slightly shorter distance to compensate for the size of the actor), then divide this value by the same value we just subtracted from (i.e. 3000-2500 -> 500/3000), and this gives us our strength as a percentage.

You will notice I used the OnPerceptionUpdated event to drive a for-each loop that grabs only the hearing sensory information, as this calculation is only relevant to hearing.

EDIT 2: Realized this grabs information about all sensed actors and not just the updated ones, and may not provide functional values. Further testing would be needed to generate a working result, but it is doable in Blueprints. Could check updated actors against sensed actors of a particular sense type, and get only the relevant data. Not entirely sure yet how it handles multiple stimuli from different sense types at the same time.