Posted May 17, 2023 by will2781
This is the line of sight script.
The AI draws a mesh by calculating the triangles and vertices needed.
When the player is spotted in this mesh the AI will transform.lookAt the player.
The player is spotted by drawing raycasts within the mesh and detecting if it hits a gameobject with the specified layermask.
This is what is happening in the gif (The AI keeps looking at the player).
A later addition will be a lose screen, which will stop this constant transform.lookAt issue