# AI Perception can see through walls

**URL:** <https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698>\
**Category:** AI\
**Tags:** unreal-engine, walls, question\
**Created:** [October 15, 2018, 8:56pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698 "2018-10-15T20:56:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 8:56pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/1 "2018-10-15T20:56:11Z")

</div>

Hello,

Created a AI enemy and he can see me through walls. Is there an option in the behavior tree that says cannot see through walls? In the BT is has, “Move To” and even if the AI is behind a large long wall the AI can see through the wall and will run all the way around and shoot at me.

Thank you,  
John

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 15, 2018, 9:35pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/2 "2018-10-15T21:35:26Z")

</div>

Do your walls have collision volumes? AI should not be able to see through objects by default. Also do you have any other AI senses setup?

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 9:43pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/3 "2018-10-15T21:43:33Z")

</div>

Hey Steve,

Thank you for the reply! I checked to make sure there was collision and that it is set to block all, I tried a few different static meshes and they all do the same thing. When you turn on debug you can see the AI come through the wall.

 ![256675-bt2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/b/1bb779d76d2a6f4ea4124635c3fda86984a62160.jpeg)

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 9:43pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/4 "2018-10-15T21:43:53Z")

</div>

Hey Steve,

Thank you for the reply! I checked to make sure there was collision and that it is set to block all, I tried a few different static meshes and they all do the same thing. When you turn on debug you can see the AI come through the wall.

 ![256675-bt2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/b/1bb779d76d2a6f4ea4124635c3fda86984a62160.jpeg)

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 9:44pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/5 "2018-10-15T21:44:51Z")

</div>

![256676-bt.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/8/c/58c4eb683b4145cbb9f25fd73e079907bba23a18.jpeg)

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 15, 2018, 9:56pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/6 "2018-10-15T21:56:48Z")

</div>

No problem. How are you setting the player in the blackboard?

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 10:03pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/7 "2018-10-15T22:03:57Z")

</div>

Just made a player key and gave it actor.

 ![256677-captubt3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/a/3eaf7249f44bd16fab864e4d4355108597104d0f.jpeg)

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 15, 2018, 10:10pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/8 "2018-10-15T22:10:14Z")

</div>

Right, but how are you actually setting that player value? It looks like maybe in your AI service?. Because I do not think the AI is actually seeing you, its just moving toward you because that value is set. When AI perceives something it will actually draw a debug sphere on top of what it is perceiving. That green line is just its perception vision angle.

So the issue is either in your AI service or in your AI controller if you are using the On Perception Updated event.

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 10:16pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/9 "2018-10-15T22:16:18Z")

</div>

We have to be getting closer 🙂 I have been working all day on this ☹  
Thank you for helping me!  
You are right, the player is being set from the AI-Service, does this look correct?

 ![256678-bt4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/5/84590d605226514a349712d9397e80b0e4035953.jpeg)

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 15, 2018, 10:25pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/10 "2018-10-15T22:25:55Z")

</div>

Yes, this is exactly your problem. You need to get rid of this service and do this a different way. The AI is not seeing through the wall, in fact the AI is not seeing you at all. You are just setting the player value every service tick, then you are telling the AI to move to the value that is set (your player).

If you only want the AI to move to you when it see you, then you need to do this in the AI controller. (there is a way to also do it with a service but is more involved).

The AI perception component has an event on it called On Target Perception Updated. This will give you an actor and stimulus that the AI has actually perceived, then you can use that value to set the blackboard key.

Here is a really simple example, but you would probably want to cast the actor to make sure its the player, or do any other checks before setting the value. You will also need to make sure to unset the value as well.

 ![256682-annotation.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/5/405b58ce9ec37f9cac23e66bbda08ead1fd2d496.png)

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 15, 2018, 11:34pm UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/11 "2018-10-15T23:34:29Z")

</div>

Thank you for the detailed reply! That make sense, I created the changes like you said and then tested and everything looks good except the enemy is blind :0 He has no sight, what do you think could be causing this?

 ![256693-bt5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/e/86e0574c33f1e0cfdcf7b305bd2f23017604ab8c.jpeg)

---

<div class="post-metadata">

**Author:** ![JohnADaniels](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/johnadaniels/32/1080686_2.png) [@JohnADaniels](https://forums.unrealengine.com/u/JohnADaniels)\
**Post date:** [October 16, 2018, 1:46am UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/12 "2018-10-16T01:46:28Z")

</div>

Thank you for all you help Steve! It is working now, the following information also helped.

"By default, AI Perception only detects enemies (actors assigned to a different team). However, actors do not have a team by default. When an actor doesn’t have a team, AI Perception considers it neutral.

As of writing, there isn’t a method to assign teams using Blueprints. Instead, you can just tell AI Perpcetion to detect neutral actors. To do this, expand Detection by Affiliation and enable Detect Neutrals."

> **[Unreal Engine 4 Tutorial: Artificial Intelligence](https://www.raywenderlich.com/238-unreal-engine-4-tutorial-artificial-intelligence)**
>
> In this Unreal Engine 4 tutorial, you will learn how to use behavior trees and AI Perception to create a simple AI character that roams and attacks enemies.

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 16, 2018, 4:53am UTC](https://forums.unrealengine.com/t/ai-perception-can-see-through-walls/435698/13 "2018-10-16T04:53:19Z")

</div>

I apologize for not getting back to you sooner, I would have mentioned that but I assumed you already had that part setup. But im glad you got it work. 🙂
