Author: Tyler Sessler
Creating multiple instances of an enemy seems like a daunting task at first. So many variables, logic, components, things you need to organize to get every instance working. Developers would spend countless hours repeating work they've already implemented. Every enemy needs health, experience, collision hitboxes, preset variables.
I started with a simple BaseEnemy class which all others are inherited from. It contained a health component, experience variable, and a few other basic implementations. However, when it came to getting started on the specific enemies, I quickly started to realize just how much I was duplicating over from one enemy to another. It started with broader concepts such as attack functions and stat variables, then moved into things like collision components for attacks, and eventually lead to the smallest of things like anim notifies or delegates. All of these things I would need multiple times over.
In the end, after creating 2 instances of an enemy, I learned what things can be done inside of the BaseEnemy- almost everything. At a simple level, my enemies now have approximately 30 lines of unique code only, compared to the 150 or so before. While I understood the value at a basic level, I now have obtained the experience to understand its usefulness to an even greater extent.
The video below shows how much code is inside of BaseEnemy vs. DraugrEnemy.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.