Thanks! The cones are a series of raycasts that we shoot out from each enemy's origin. So we created a Ray object that:
- Shoots from origin of Enemy objects
- Checks for Object collisions (if any)
- Returns the first object hit
- Does an additional collision check to determine which side of the object Sprite it hits
- sets the draw distance of the ray to the point on the side its colliding on. (and call draw_triangle() on each pair of consecutive rays)
- If the object is the player, changes the enemy state so it attempts to chase the player, instead of patrolling an area
I hope that answers the question, but if you want to take a look, the source code is available on github: https://github.com/nKowalchyk/StealthWrench