How to Create variants with different scripts interact with player

So I have a bit of an issue. I have coded alot of actions that the player can do based off of my original enemy, Enemy A. But I now want to make a new enemy, Enemy B. But right now, my player script is coded right now to mess with the movement of Enemy A by accessing it’s movement component and setting its speed to -1 (to make the enemy run away).

But the problem I have, is that Enemy B’s movement pattern is different from Enemy A, so I have to make a different movement component for Enemy B. But now I’m in a bit of a pickle because, the players actions are coded to access Enemy A’s Movement script called “Follow.” But I also want the player to be able to change Enemy B’s script called “Charge.”

Is there anyway for me to stream line this process? So that my player can change any enemies movement script, without having to hard code in the unique name of each script? Can I use like prefab varients or something like that? I’m new to unity, but really love coding. I’ve just been so frustrated with issue… Any help would be greatly appreciated!

Probably best to redesign using OOP concepts:

You will create a base monobehavior class that has all of the shared attributes various enemas have, like speed, health, moment distance, strength, … what ever, as variables. Also, any shared behaviors as methods/functions. Like, maybe all enemies sleep to recover health. You will not add this script as a component to anything.

Then you will create your individual enemy class types which will inherit from that base class. In these you will add any unique attributes and behaviors. So in your example, one will Charge and one will Follow, or what ever. You will therefore have methods and functions that implement those behaviors in each of your respective child classes.

Yes, then add the respective child scripts to prefabs for each of your different enemy types.

Google Unity OOP programming for a lot of tutorials.