# How can I check if player is being seen by AIPerception sight?

**URL:** <https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [May 15, 2024, 9:24pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840 "2024-05-15T21:24:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 15, 2024, 9:24pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/1 "2024-05-15T21:24:39Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/e/a0e7245d0c13fede5432c1b0a2b777518cbcb2c0.png)

The idea is that the enemy will do different things, if i’m being seeing and a few seconds after I’m not being seen anymore.  
However, the branch is always turning false. So technically, even though the enemy follows the player, it is returning it as not visible.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/6/086e9e71e9d5bdacc774af783524087a4e839ac9.png)  
I get all of this on top.

Pleases help me. 🙂

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 15, 2024, 9:47pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/2 "2024-05-15T21:47:35Z")

</div>

Hey @itsgoshi!

It seems you aren’t specifying which AI controller to use. If this is on your AI Controller Blueprint, you can get rid of this node and use the AI Perception component- you don’t have to use extra nodes for this, just “GetAIPerception”. 🙂 If it isn’t on your AI Controller Bluperint, you need to specify an actor in this node. All of the errors I can see are caused here, with this node.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/8/e/d8e8d9c7358904b48065a97b396d8ddc4adf08f0.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/3/e73bab5b86365845576bcfe9540b5f938c6d7210.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/f/11fe2ee0374fc093a8cf41ed64a18c6db87a4bdb.png)

Edit: @itsgoshi Updated with more description and images!

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 15, 2024, 9:57pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/3 "2024-05-15T21:57:09Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/3/7c3eb147a0e55b3d1d7ef6232e10f98fecfbdb87.png)  
Hello! IS this what you meant?

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 15, 2024, 10:09pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/5 "2024-05-15T22:09:27Z")

</div>

So I did this. And while some of the red lines disappeared. I still get a not visible trigger the second the enemy sees me. This is what some of the other stuff looks like.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/0/4/b046a25646e6976c888c8d5f31e9610129b51128.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/1/5612651125b6d912a68ea7c38b5330eddb5990dd.png)

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 15, 2024, 10:12pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/6 "2024-05-15T22:12:56Z")

</div>

Try this: It’s basically the same thing with less confusing nodes.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/4/2943e074c6bdc1a9d0d188e8965ce028bd04964b.png)  
**On Target Perception Updated** returns the stimulus and actor that was observed, if you need it.

Then _IsSeen_ will be set for anything else you may need it for in your code. Then it answers true or false from there, going into chase or search locker events! 🙂

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 15, 2024, 10:20pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/7 "2024-05-15T22:20:34Z")

</div>

I see you’re using “On target perception updated”. The thing is I was using that for an event where the enemy will be distracted by a thrown object. I’m assuming I can’t use it for both these events?

Also, I did what you suggested, and as soon as the ai loses sight of me, it just stands still. It is supposed to first go to the nearest locker. And if I’m not there, go to a random one.

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 15, 2024, 10:24pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/8 "2024-05-15T22:24:49Z")

</div>

You can, you just need multiple options. Only one event node. You can use multiple checks such as “== Class” to check if it is a thrown object class, or if it is “Character” class.

So Actor → Get class → == “Character”? → Branch, on True, run this, on false, run thrown object code. Things like that. 🙂

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 15, 2024, 10:38pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/9 "2024-05-15T22:38:13Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/2/71242513fbd55b0d0960dd29e43924e211a03da7.png)

🤔  
IS this what you were thinking?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 16, 2024, 1:01am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/10 "2024-05-16T01:01:25Z")

</div>

More like this!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/b/8/0b8c13e254acf9d71f007c309cb36af70628783e.png)

You can’t compare actors to actors because they receive new names when they spawn, so they’ll never match! 🙂

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 16, 2024, 1:06am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/11 "2024-05-16T01:06:34Z")

</div>

That makes so much sense. The enemy kept chasing me even after I threw the object LMAO.

However, where do I put the is seeing bool now?  
That would be the deciding factor in whether or not the enemy checks out the lockers or not.

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 16, 2024, 1:11am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/12 "2024-05-16T01:11:45Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/3/2f329d1f781049c12f466a9017b59ec253e62fd4.png)  
This is where we’re at now

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 16, 2024, 1:13am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/13 "2024-05-16T01:13:03Z")

</div>

Tried to connect the object to the actor class, but the enemy still follows the player instead.

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 16, 2024, 3:02am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/14 "2024-05-16T03:02:00Z")

</div>

Okay, so there are definitely some things to fix up! 🙂

It’s chasing the player non-stop because both of the == class nodes are BP\_MC (I assume that is your main character blueprint). The one leading to “GoToNoise” needs to NOT be your player character.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/5/6b5af8340d4a298e04f732745df0005917455fd3.png)

Also, get rid of the cast in “GoToNoise”. That’s casting with no object and will create an error.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/c/0/8c016c89f14967321f13168c60b8809a368e02a5.png)

Finally, hook up the False/false output to be the “Check Lockers”.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/d/d/7ddbc7dfa898410486f12c5192671634405115a5.jpeg)

So:

If sensed class == BP\_MC, chase player. If not, move on.  
If Sensed class == thrown object, investigate. If not, move on.  
If Sensed class == Neither BP\_MC or thrown object, search lockers.

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 16, 2024, 7:09am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/15 "2024-05-16T07:09:06Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/e/d2e66ac0702aabbac1c1532025258996a82a11da.png)

Hey! So I tried it like this.

When I debug, this is what happens.

The player is still followed by the enemy, and I get TWO printed strings for seeing.  
I can’t see that I’m missing anything here as of right now.

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 16, 2024, 6:23pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/16 "2024-05-16T18:23:31Z")

</div>

Well, when it is sensing the player, it should follow the player, and re-run that first line over and over and over, every time. When it doesn’t see the player is the only time the bottle should work.

If you want it to stop chasing the player, on the first line, put a “re-triggerable delay” node after the “Visible” printstring node. On that node, you’ll put in the time it should take for the enemy to stop chasing if it doesn’t see the player.

Then you need to make an event node to do the “notvisible” line. Here’s a mock-up going off of what I had in that test project

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/6/dc6e234605782812d4e66c8263960ace2350e0d9.png)

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 18, 2024, 5:55pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/17 "2024-05-18T17:55:18Z")

</div>

This is what it looks like right now.

Following the player

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/9/e9995a7b980062082664af4d83587ef76c8b7d39.png)

Go to nearest locker

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/b/f/cbf44631a3658302bd440cdb02241f0b03dceaa4.png)

Code for catching and killing player

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/e/2ee6bfa8a1e0b73a42e6b4202de2ddc9a4615429.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/b/3/cb3bcd791eca9e856442e98022375d4d612cd9cd.png)

Okay so this is what everything looks like right now for reference. I have been doing stuff offline of course.  
Sorry for the hassle, I’m kind of new to programming.

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 20, 2024, 6:23pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/18 "2024-05-20T18:23:55Z")

</div>

Hey @itsgoshi, sorry for the late reply.

I can see some things that could cause issue, but let’s touch base for a second. You are showing a good bit of code for reference- that’s great!

But what is working and what isn’t? 😛

When you change something, test it out and let us know what happens. 🙂

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 21, 2024, 2:55pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/20 "2024-05-21T14:55:26Z")

</div>

Hello! It’s okay! I got to work on my menus in that time.  
So many things are happening. I did add what you said. So one thing that happened is that the enemy just stops in front of doors.  
When this happened I tried hiding in the nearest (I think?) locker, and somehow it gave me a game over screen.  
☹  
I also saw it open a random one, but from the other side of the door. 💀

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/0/ae0980ef6378b004b2cce2e7dc50d0bd6407f710.jpeg)

I also get these

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/9/33911448037c7ca63c26e597bfb5825a8682f91d.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/f/7bf8bb44cc13881d50fb60089383a27eed349d64.png)

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 21, 2024, 6:04pm UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/21 "2024-05-21T18:04:19Z")

</div>

So the errors are due to “TargetLocker” not being set.

Part of why you’re running into a lot of issues is you’re trying to do everything all at once, you need to focus on one thing at a time, get it done, and move on! 🙂 It helps cut down on bugs to do things this way.

So, first we’ll tackle the door. Then the lockers.

Open your level and go to one of the doors, then press the “P” key on your keyboard. There should be a lot of green space. This is your navmesh render and shows you all of the walkable area for your AI. If there is a gap in it, that means the navmesh will not allow the AI to walk there, so look at the door frame and make sure it’s got green floor! 🙂 If it does not, we now know what the problem is and we can work on tackling it!

If it DOES have green floor, either your door is too small or your character is too large, likely.

Test that out and let’s get to work!

---

<div class="post-metadata">

**Author:** ![itsgoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itsgoshi](https://forums.unrealengine.com/u/itsgoshi)\
**Post date:** [May 22, 2024, 8:51am UTC](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840/22 "2024-05-22T08:51:43Z")

</div>

Okey! So I checked off “Can affect Navigation” To false on both the door frame and door. If the door is closed, the enemy literally just gets stuck running at the door itself in the corner

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/6/f/a6ff051bd04b82b76290161dad14503a3119631d.jpeg)

If it’s open. It will run through. Later I will add a code for the AI to Open the door too.

But yes. That’s one issue kind of solved.

[Next page](https://forums.unrealengine.com/t/how-can-i-check-if-player-is-being-seen-by-aiperception-sight/1857840.md?page=2)
