Issue with ai senses config

Hello, i have some problem with ai senses config, as you see in that png in array ai sight config must be under index 0 and ai hearing config under index 1, but in reality they are mixed up(sight is under index 1 and hearing is under index 0 ) and i can’t understand the problem.

Isn’t it totally up to you to fill in the senses config array? So you define, which index is which sense. Let me check for some example in my project.

Adding new AI Perception component to my AI Controller: empty

grafik

Add first sense - you have the choice

grafik

So you can setup it as you like, I even could define the weird setup on the right :slight_smile:

So simply change the dropdowns to match your index values.

I know that and i choose that sight config must be under index 0 and hearing
under index 1 , but there is some kind of bug and this indexes just mixed up and when i start game this indexes are not on their own place. Let me show you

![image|690x178](u


pload://nFi9vcemN52GDAd1Ns8dlrK5rRc.png)


As you see i want to get sight config which is under index 0 and if sense is succesfull, print true, but it prints me true, when ai hearing me, not seeing, but hearing config is under index 1

I tried everything even change the version of UE (version 4.27 worked strangely on my pc and i returned to 4.26) and at first glance everything fixed, but when i saved, exit and return to project,
the situation repeated without any reason

I restarted project and it fixed again, i think it’s a bug

Ah, I see what you mean. I did not use that function, but just gave it a try.

Having my Senses Array:
Hearing at index 0
Sight at index 1
and just added another one for AI Damage at index 2 (does not get triggered)

and it prints

LogBlueprintUserMessages: [AIC_Fox_C_0] AISense_Sight - true - at index 0
LogBlueprintUserMessages: [AIC_Fox_C_0] AISense_Hearing - true - at index 1
LogBlueprintUserMessages: [AIC_Fox_C_0] - false - at index 2

The order is different indeed.

A suggestion for a workaround:

Instead of relying on the order in the array, what about using the Get Sense Class for Stimulus, as in my example, and decide on this - this way, you are on the safe side.

Would be interesting to to look into the source code - maybe the order in GetActorsPerception is just hard coded and does not reflect the order in the array - which at least would be very misleading, if not to be considered as a bug.

Edit: also weird - removing my damage sense from array required restart of editor to get it out of the reported list. So the array does not seem to be immediately used in the function, or some caching happens…

1 Like

I switched to version 4.26 and now it’s working well. I guess it was some problem with version 4.27. In any case, thanks for answer:))))))
P.S. Sorry for my mid english

You can’t really output something from one event inside another event, that’s… definitely a problem.

In your On Perception Updated, check the type of stimulus received, and alter it as needed in that event, and do any output from that same event.

There’s no need to query the array and do anything with it

I am just checking the bool variable in event tick in this png not more. The problem was in swaped indexes and i solved it by changing the version of UE from 4.27 to 4.26. There were also another problems like this: Main Menu flickers on Unreal Engine. The version 4.27 worked very strange on my pc but everything back to normal, when i returned to 4.26

It may work, but it’s not stable, nor correct.

You should be determining your flow based on which sense is receiving the update, rather than iterating an array and using arbitrary magic values.

The problem is not swapped indices, the problem is having code that is checking an index.

1 Like

Hi @ale20ako021 , I had been away for some days not reading the forum. Just for your info: I did my test on 4.26 - and had that swapped order reproduced. So I do not believe, that you really have a stable solution for that problem just by going back to 4.26. It may work, but it is not guaranteed to work.
I really recommend you to check the sense class to be absolutely sure and avoid any bad surprise in the future.

1 Like

I think I understand you. I will definitely take this into account

Do you have any idea why this happened? All i can say is that it started when i updated to 4.27 from 4.26 and seems to be it fixed when i back to 4.26

ohh, i remember one thing, when i converted my project from 4.26 version to 4.27, UE was crashed two or three times during the convert.
P.S. When i returned back to 4.26 of course i could not convert project from the newest version, and used my older saved project, which i saved just in case before the update

anyway i will check everything and let you know if something is wrong

I don’t know why it could have happened, but just wanted to let you know that I did have that behaviour on4.26 as well. I did have a quick look at the source code in 4.26, and I did not find any parts, where an access to the configured order is done… just a short glimpse to the code, and it gets a little bit complex, so that chances are, that I overlooked some details…

Yep, you were right. It didn’t help. Do you have some other idea to fix it or what is the problem ? It’s actually a bug, which i don’t know how to fix