top of page
Search

Game AI Line Of Sight Enemy

  • Nolan Roher
  • Apr 30, 2019
  • 1 min read

I recently wrote a bit of code that involved creating an AI enemy that detects players based on whether the player is within their line of sight. This is the GitHub link with an explanation featured below: https://github.com/maniacalspy/GameAIFinal/blob/master/Assets/LOSEnemy.cs


The enemy currently keeps track of the player and if they are within a certain distance of the player the enemy then checks the angle between straight in front of them and the player to simulate a field of view. If the player is within the field of view then the enemy double checks to make sure there's no objects blocking that line of sight, and then from there the enemy calls the event for what to do when it finds the player, which is currently set up to change the enemy's state and use A* path-finding to determine the best route to the player's last seen position before moving to it. After moving to the destination, if the enemy does not see the player it will quickly turn 180 degrees before going back to an idle state.

 
 
 

Recent Posts

See All
Unreal Capstone Project GitHub Repo

https://github.com/maniacalspy/Nudge This is the link to my senior capstone project's Github Repo, the project has been my primary source...

 
 
 

Comments


  • LinkedIn Social Icon

©2026 by Nolan Roher-Brown.

bottom of page