Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Enemy State Machine




Hello back again with another blog post for Team Terror Forge. The game is starting to make some really good progress we are implementing and reworking some game mechanics as well as adding new features. This week I was working on the enemy mechanics mainly adding the new feature to make the enemy transition to do different actions. This implementation required me to make a state machine for our enemy's AI


There were some issues I ran into trying to implement the state machine. The first issue I ran into was transferring the roaming code I had earlier to fit with the state machine logic. To fix this issue I spent some time learning about state machines and their structure and how they are planned out  I set up 5 scripts each holding different logic one was a state manager the other was a state base and the remainder were the state the enemy would have.



The second issue I ran into was my roaming code not working. The issue was I wasn't able to use a transform. position or start coroutine which caused my AI not to move and my function not to be called.  I spent some time trying to figure out why I didnt have access to these and realized they are of class MonoBehaviour and I had to add that to my code but my base state class couldn't derive off that class either so I added the MonoBehaviour to my state manager and had my base state derive of my manager as well fixing the issue.


Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.