Hello,
I’m currently building a stealth-based game and I’ve managed to get the player to have a visibility rating (in percentage) in a pointlight actor. So the closer I am to the light, the higher my visibility of course. What I would like to do now is to get the AI to read this figure and ignore my character if it is below 35%. Currently, the blueprint for the AI is simply “see target, chase target”. What do I have to add to the simple tree to make the visibility percentage a component of its sight perception? As in “Player invisible under 35%”.
If anyone can help, or point me in the right direction I would be very grateful for your input.
Please be aware I’m a bit of a thicko when it comes to unreal as pretty new to this.
Hi, I’ve never used PawnSensing, only AI Perception Component (AFAIK PawnSensing has been deprecated for years now…).
Generally speaking you have at least two options:
(-) Build another layer in between the build in perception logic and your own (so not directly act when the perception component tells you it perceived something, but on timer loop through everything it currently perceives and then check whether that has a sight strenght above 35% and then act on that)
(-) Inject it to the build in perception logic. In AI Perception you can implement the CanBeSeenFrom function of the IAISightTargetInterface (need to do this in C++). Then inside that function you could either only return true if the sight strenght is above 35%, and/or return this sight strenght as OutSightStrength which you can then access as the StimuliStrength from the AI Perception Component. There you can also do more complex stuff, like tracing to separate bones (e. g. if the AI can only see a hand or a foot of the player, then you can return lower sight strength / return false as compared to when the AI can see head and torso, or trace to different bones and build a sight strength from that).