Pathfinding to avoid pathing in a player’s field of vision

Hello,

I am trying to figure out a way to have Pathfinding Service avoid pathing in the field of vision of the player. I want the AI behaviour to basically encourage sneaking up behind a player.

  1. Create a physical part that is tracked to the head of the player
    The problems with this approach is what if I have a wall? The vision cone will ignore that and pierce through the wall.

I’m a bit lost as how to solve this problem. Maybe I do something with CSG to cut and slice this initial vision cone apart, but I’m unsure how to actually do that?

Shapecasts might be the solution for you.

https://devforum.roblox.com/t/introducing-shapecasts/2320655

I tried looking into it, but my only problem is that this stops at the immediate first sweep. Which implies if I part even partially blocks the view between the player and part, it will only register the part in question without letting me know it only partially intersects.