I was trying to make AI Target System, I always use PawnSee. But I hear about AIPerception, and try to use that. But I dont understand exactly how it works, because as you guys can see, have alot AI on the view, but he just indentify 5. I setup the angle of vision 180º, the distance to 10000, but still dont work.
So I have some questions:
Is AIPerception a good choise or is better stay with PawnSee ?
If AIperception was a better choise have there any tutorial ?
AI perception will return actors based on their own perception of other actors with an AI or player controller, as far as I know.
A few things to note:
in the AI perception component details on your AI controller - under AI Perception, add AI Sight, open that and under sense - make sure detect enemies, friendlies and neutrals is enabled -I haven’t worked out actual ‘teams’ inside the Perception component yet - pretty sure that would be the team sense.
Now you can set the focus of the ai controller with either your behaviour tree tasks or blueprint.
Rather than take last index, add all the actors to an array variable - then use whatever system that fits your game to filter whom the AI focuses on. For instance I am making a ‘value’ system based on health, equipped weapon and distance from enemy to handle AI targeting.
Hope this helps
What I dont really get about the AIPerception is why the last index that would to give me some value like 20, just give 5 actor.
Or I have to do some thing like:
But if I do something like this, when the AI dont is seeing any other pawns, the “NewVar_0” will still got all the player that the AI dont is seeing anymore.
So if I make a AI based on got the player with lower life to target, it could run into a player that is far away from his view.
How you handle that information is up to you, but in my case - I am adding new actors to a separate array as they are found, and using that as the AI ‘memory’,
from there, either on tick or maybe when a new perception is updated - run through the whole array testing for visibility via a lineTrace. How you want to filter your array is entirely up to you.
but rather than an insert, I simply use an ADD (note though that I am playing with the idea of a struct array that holds particular details so I don’t get bogged down in multiple tests everytime i filter it…
note that if you are particularly concerned about old enemies being ran too from past memory - you could always give your ai a goldfish memory and ‘clear’ the array at the end of your execution line lol… as for mine, I will add forgetfulness some time down the track based on a timer most likely, but due to the kind of game im making it might actually be overkill in my case…