AI Sight perception slow at updating

Hi!

I’m having some issues with the AI Sight perception. Whenever I have a lot of Actors registered to the sight perception it eventually gets very slow at updating. Even if the source actors are very far away.

My main use case it to detect other AIs and buildings in our game, hence why the Stimulus Source Components are so many.

I checked the “SightQueriesOutOfRange”, and it had 30k entries in my case.

Maybe I’m using it completely wrong, or what would be the way to use it in my case?

Best Regards,

Alex

Steps to Reproduce
-> Time slice the sight perception to 1ms

-> Register 700 actors to sight perception (using AIPerceptionStimuliSourceComponent)

-> Spawn 30 AIs with Sight perception enabled

Hello!

Our sight perception system was originally designed for “seeing” hostiles such as enemy Pawns rather than points-of-interest style look at targets. That said, it should still be viable for larger number of stimuli sources. Do all sources need to have sight stimuli? Have you tried adjusting the frame budget for sight perception to allow for more traces and cpu time slice per tick? When you mention it being slow, is the framerate/perf dropping for the whole project or just the sight perception processing seeming to lag behind?

-James

Hi!

It’s just the sight perception processing that lags behind. So my enemies are very slow at reacting.

It is working well if I increase the budget, but for sure get’s more costly.

I ended up following your advice and not use stimuli sources for the buildings and now it’s working very well.

Thank you!

Regards,

Alex

If you want to use the perception system, you might look into creating a custom sense for “noticeables”. You could tweak how often it updates as well as the logic and data it needs to process. Another alternative would be to look into using the MassLookAt system. You can have entities associated with Actors using the MassAgentComponent. We used largely for things that the NPCs in City Sample could look at while they were walking around the city. It was designed and developed for Mass, so there may need to be some changes made to support an Actor first approach, but I believe it should be possible to use that subsystem and keep performance.

-James