How can I stop the enemy from seeing through walls.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SDGN16

When the player on the scene enters the enemy’s field of vision, the enemy is following her. but even if there is a wall between the player and the enemy, the enemy notices the player. How do I make sure that my enemy does not see the player when a static object enters between the player and the enemy?
(My scene is 3d and there is an area from the enemy, it can see its 360 degree view.)

have you tried using a raycast ? It’s a good way of checking if there’s wall in front of your agent

bloodsign | 2021-03-01 14:48

but raycast only works for one way and I use area. I don’t know how to do it with raycast.

SDGN16 | 2021-03-01 16:51

:bust_in_silhouette: Reply From: exuin

You can use both an area and a raycast. When the player enters the area, cast a raycast to the player to see if there’s a wall in the way. Continually check to see if the player has gone behind a wall by updating the raycast’s end point.

the enemy’s angle of view is 360 degrees. Shouldn’t I use a lot of raycast for this? Could you please give me an idea or an example?

SDGN16 | 2021-03-01 19:35

Sorry, I don’t really do 3D. But you only need one area and one raycast. Just move the one raycast’s end point around.

exuin | 2021-03-01 19:40