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"

AI Perception can see through walls

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

Product Version: UE 4.20
Tags:
more ▼

asked Oct 15 '18 at 08:56 PM in Blueprint Scripting

avatar image

JohnADaniels
60 4 6 8

avatar image Steve SybrSyn Oct 15 '18 at 09:35 PM

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?

avatar image JohnADaniels Oct 15 '18 at 09:43 PM

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.alt text

bt2.jpg (164.0 kB)
avatar image JohnADaniels Oct 15 '18 at 09:43 PM

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.alt text

avatar image JohnADaniels Oct 15 '18 at 09:44 PM

alt text

bt.jpg (275.9 kB)
avatar image Steve SybrSyn Oct 15 '18 at 09:56 PM

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

avatar image JohnADaniels Oct 15 '18 at 10:03 PM

Just made a player key and gave it actor. alt text

captubt3.jpg (96.4 kB)
avatar image Steve SybrSyn Oct 15 '18 at 10:10 PM

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.

avatar image JohnADaniels Oct 15 '18 at 10:16 PM

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?

alt text

bt4.jpg (215.6 kB)
avatar image Steve SybrSyn Oct 15 '18 at 10:25 PM

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.

alt text

annotation.png (250.5 kB)
avatar image JohnADaniels Oct 15 '18 at 11:34 PM

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?

alt text

bt5.jpg (162.0 kB)
(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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."

https://www.raywenderlich.com/238-unreal-engine-4-tutorial-artificial-intelligence

more ▼

answered Oct 16 '18 at 01:46 AM

avatar image

JohnADaniels
60 4 6 8

avatar image Steve SybrSyn Oct 16 '18 at 04:53 AM

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. :)

(comments are locked)
10|2000 characters needed characters left
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