Implementing Enemy Behavioral Script

I am trying to implement enemies into my game and have two ways to do so:

  1. Have multiple behaviour scripts for multiples enemies
    Pro: Less messy
    Con: Affecting (damaging) enemies requires cycling through all of the scripts to determine which one the enemy has.
  2. Have one behaviour script for all enemies
    Pro: Affecting enemies less messy
    Con: Moar messy
    Which one? :smiley:

It depends on your game design. How similar are your enemies?

If they are more similar than different, you would probably be better off with one script that has multiple options, where you can individually set things like speed or accuracy or aggression for each enemy, but still use the same code for each.

If enemies are more different, then you may want to write a different script for each.

If you have classes of enemies, you could use a middle ground, with one script per class of enemy. Ex: one script for ranged enemies, one for melee, one for turrets, etc. You could still have variables that let you customize things some (e.g. rate_of_fire variable to let different ranged enemies shoot at different speeds.)

Last, consider that you are still in a prototype stage. If you make the wrong choice, no big deal. Lots of things are going to change, and you’ll probably have to rewrite your code no matter what. So my last piece of advice - do what feels right, and it’ll be okay in the end.