top of page

[DEMO] Enemy A.I. - State Machine

  • Writer: MJ Lindsay
    MJ Lindsay
  • Mar 8, 2022
  • 1 min read

Updated: Apr 5, 2022


ree

This enemy can Patrol, Chase, Search, Attack, Listen, Retreat.


Enemy eyeslight is done using raycasting. Walking within the orange area will not alert the enemy, unless the player is running. If the player walks within the red area the enemy will hear them regardless of speed.


Patrolling - The enemy will move from one set patrol point to the next before returning to the first. By using an expandable array, as many patrol points as you want or need can be added.


Listening - If the player speed is above regular walking speed while within the listening area (orange) the enemy will turn towards the noise, being able to find the player.


Chasing - If the player is spoted by the enemy raycast, the enemy will chase after the player as quick as it can


Searching - If the player manages to get away, the enemy will stop and search the last known spot the player was in. If the player re-emerges the enemy will return to chasing.


Retreating - If the enemy is unsucessful in searching for the missing player, the enemy will retreat back to its starting patrol point.


Made in Unity, 2021;


Try out the demo for yourself: CLICK HERE

Check out the code on GitHub: CLICK HERE

Comments


I would love to hear from you!

Thanks for submitting!

© 2023 by Train of Thoughts. Proudly created with Wix.com

bottom of page