x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Detect when AI Perception loses sight of the player?

I have watched all the you tube videos on the AI perception component and have got it to detect the player successfully but can't work out how the lose sight part works. I just need a simple blueprint that will detect when the AI can no longer see the player with a boolean output so I can change the behaviour tree. Any ideas?

Product Version: UE 4.8
Tags:
more ▼

asked Jun 28 '15 at 08:34 PM in Blueprint Scripting

avatar image

anti_zer0
65 10 16 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

@gloim's answer is not quite correct. GetActorsPerception will return false only if given actor was never perceived. To see if you lost perception of an actor you need something like this

alt text

Mind this setup assumes you have only one sense specified (sight).

Cheers,

--mieszko

more ▼

answered Jun 29 '15 at 12:02 PM

avatar image

MieszkoZ STAFF
7.3k 223 57 412

avatar image anti_zer0 Jun 29 '15 at 12:24 PM

Ok great thanks for the help I'll have a go at this later and let you know if it works!

avatar image anti_zer0 Jun 29 '15 at 01:00 PM

it works perfectly!!! been trying to do this for 2 days its been driving me crazy! I'm not sure how it works but it does :)

avatar image gloim Jun 29 '15 at 01:02 PM

Oh thanks MieszkoZ I didnt know that...now you pushed me back to my perception BPs :(

avatar image MieszkoZ STAFF Jun 29 '15 at 01:04 PM

I'll be adding a lot more convenient notifications for 4.9, so it's going to get easier :)

avatar image Alfica Jan 01 '16 at 05:13 AM

Hey, im trying to replicate this. But i cant conect the "get AI Perception Component" to my AI Control (self) . And in the image you share, i cant see where is it conected. where i have to conect that node?
Thanks

avatar image anti_zer0 Jan 01 '16 at 07:45 AM

Hey, this is what mine looks like. This is on the AIController blueprint.alt text

avatar image mtrebi May 17 '16 at 09:17 AM

This helped me a lot. In case someone needs it in c++ :

  FActorPerceptionBlueprintInfo Info;
                     GetAIPerceptionComponent()->GetActorsPerception(PlayerPawn, Info);
                     
                     if (Info.LastSensedStimuli.Num() > 0) {
                         const FAIStimulus Stimulus = Info.LastSensedStimuli[0];
     
                         if (Stimulus.WasSuccessfullySensed()) {
                             //Player in sight
                         }
                         else {
                             //Player out of sight
                         }
                     }


avatar image callmeEarly Apr 06 '17 at 12:21 PM

I tested this with two AI enemies, and they will block the sight to each other and one will return "lost sight" to the target (Player Character) even it is very closed to the target with Vision Angle 180 degree. Anyone happened the same? Or, did I miss something I gonna setup? please advise. Thank you.

avatar image adzonic Apr 11 '17 at 09:15 AM

same problem here.

avatar image Clay Chong Oct 24 '17 at 03:10 PM

looking for solution for this same problem too

avatar image Vaheva Oct 18 '17 at 10:16 AM

Hi @mieszkoz !

I have problem. With this solution I have any output - always false even when ai see player (event). I tried to call it from ai controller and from ai blueprint - everything is fine, but no success. I have also EQS Query and it working (see can't see), however I need simple see test from bp and this is very important.

Maybe I miss some settings on sensing?

Thx's for any help!

ps. Here my log:

 Blueprint Runtime Error: Attempted to access index 0 from array LastSensedStimuli of length 0! from function: 'ExecuteUbergraph_OperatorBP' from node: Set PlayerInSight in graph: EventGraph in object: OperatorBP with description: Attempted to access index 0 from array LastSensedStimuli of length 0!


avatar image Nonlin Aug 24 '18 at 10:30 PM

I'm very confused how this can be a solution, the code says to Broadcast OnPerceptionUpdated if the UpdatedActors is greater than 0. If Sight is lost or all senses do not detected something aka sight lost aka false, UpdatedActors will be 0 and the OnPerceptionUpdated event should not fire. So if it does not fire when the sense is false, it will never be able to fire and get a false value for a sense. The only exception being if you have two senses, and one sense fires true while the other did not fire resulting in a false.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You could use the GetActorsPerception-node and use the "Return Value". True=Sensed False=Not Sensed

more ▼

answered Jun 29 '15 at 10:05 AM

avatar image

gloim
169 5 9 21

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question