How to attach different scripts to one script for different prefabs

My question arises when I started to work on a second enemy for my game. Essentially, I want to be able to use one script for the decision making of all enemies, while each prefab has a different script concerning what moves correspond to those decisions.

I was wondering if its possible to ‘drop’ scripts the same way transforms can be dropped in to access functions on one script with the same name as functions on a different script.

I’ve included a part of my code to hopefully make my question more clear:

What I would like is that the script 'EnemyMovesScript does not have to only refer to one script, but that for each prefab I can attach a different script describing the moves that are available to that enemy prefab.

Thanks in advance!

I’m not sure I understood you correctly.
is this the structure you want?
each enemy prefab contains a Decision making script and a Movement script.

where the movement script for each enemy is different?

is so, you could use inheritance.
Create an abstract base movement script, lets call it BaseMovement detailing all types of movement,
and let each enemy have its own derived class that implements all of BaseMovement class abstract methods.

that way, the decision making script could have a reference of type BaseMovement,
and initializing it with GetComponent() will fetch a reference to the derived class in the current GameObject.

Hope that helps :slight_smile: