Great week, some major improvements:
- Added health bars over enemies. I based the solution on Jason Weimann’s excellent tutorial (part 1) (part 2). I don’t have time today to post an example – will do next week.
- Consolidated enemy and NPC AI code into AI Controllers. The AI controllers can be created for a single enemy/NPC type or a group of enemy/NPC types. They inherit from MonoBehaviour and implement an AIController interface. This cleaned up a lot of code, especially for the “Giant Spider” boss, which had code across half a dozen classes.
- Improved player detection by enemies. Previously, enemies began to act when they were seen by the player. This had some drawbacks: it didn’t allow enemies to have different viewing distances, continue acting after the player moved out of sight, or track enemies other than the player. I created an ActorTracker class to maintain a list of actors the enemy is tracking. The ActorTracker inherits from MonoBehavior and gets added as a component to actors at design time. In most cases, only the player is being tracked, but this can also support situations where enemies attack each other or coordinate attacks. It’s also much cleaner.
- Shrinking the bug list. The above improvements closed out some old open bugs.
Next week, I’m fixing ranged combat, which was disabled during the recent refactoring (lots of commented out code to remove or refactor), refactoring effects/conditions, and adding some visibility-based map features (mist, darkness traps).