Enemy sight range and walls in 3d

So currently I am using checksphere to see if a player is in sight range, but what should I do if the player is behind a wall? It also detects the player, even if he is “hidden”. What should I change the detection method to ?

What you seek is commonly called “line of sight” or “LOS” and there are some tutorials out there on youtube.

You can do this with Raycasting, or other types of physical casting, to see if the line between the player and the enemy is blocked by anything.

Thanks, that’s exactly what I was looking for.

1 Like