top of page
Writer's pictureDavid Flores

Practicing Linear Algebra: Vision Cones

This is the third part of my short series on practicing linear algebra. The previous parts can be found here and here.


This time around, I decided to test my linear algebra skills by implementing an efficient version of a vision cone.

Vision Cone
To see or not to see? That is the question.

In this example scene, there are two agents. The green agent is the one that is controlled by me, while the blue one walks around on patrol. The two lines extending from the blue agent's face represent its vision cone, or the area in front of it that it is able to "see."


Once the blue agent sees the green agent, one of two things can happen:

  • If the green agent is facing away from the blue agent, the blue agent will start running towards the green agent

  • If the green agent is facing towards the blue agent, the blue agent will stand still and watch

Once the green agent manages to escape from the blue agent's sight, the blue agent resumes its patrol as usual.


Using linear algebra is a much more efficient method of implementing a vision cone compared to the other typical method of shooting a fan of raycasts every frame and see if they hit anything.

 

This is basically how the Boos work in the Mario games.


11 views0 comments

Comments


bottom of page