Composition of Enemy Behavior

Why compose Enemy behavior from multiple scripts

Tristan Engel
Jul 9, 2021

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.

--

--

Tristan Engel
Tristan Engel

Written by Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

No responses yet