I don’t use AI perception or pawn sensing because it doesn’t have good performance in my game so I made my own. For my system there is an enemy array list for two teams of AI (red and blue). Each AI knows the locations of every enemy but that’s okay and part of the game. Until now AI simply had a behavior tree task to loop through all the enemies to find the closest one to set as its target but this meant the AI would ignore enemy AI they see but aren’t closest to while pursuing the one closest to them.
So I made a task to check which enemies are visible to the AI and sets the target to the closest one. The issue is that I only knew of one method to do so - firing a line trace toward every single enemy AI on that’s in the “enemy array”, which can go upwards to dozens of actors. This happens maybe every 5-10 seconds PER AI, you can see how this might cause a problem with performance. Using the task, I lose about 10 FPS.
Anyone have any suggestions on a more efficient system for checking what enemies are visible?
Thanks!