Composition of Enemy Behavior
Why compose Enemy behavior from multiple scripts
Composition
In the future articles we will be increasing the enemy types. Instead of creating multiple copies of the enemy script and edit them individually we will try to split the enemy behavior into multiple smaller scripts. Then we we add a few scripts onto the gameobject to create various enemy types. This is called composition.
Enemy Behavior Composition
Remember every situation has different needs. Everything has it’s pros and cons. Our choice is to create 4 types of behavior scripts.
Enemy Damaged
Enemy Movement
Enemy Attack Type
Enemy Projectile
We haven’t tried composing behavior like this before so this will be interesting. In the next article we will create a new enemy type with this to test the method.