How to handle enemy prefabs with many parameters?

I am working on level design for a a japanese style shmup, nearly every instance of an enemy behaves differently, which is requiring me to have to create a high number of different enemy prefabs. Each enemy has a large number of different parameters that must be filled in each time, such as the path it follows to enter the screen, to exit the screen, health and movement speed. Each enemy also has one or more of a few different attack pattern scripts, which each have parameters such as rate of fire, bullet speed, bullet type, and more depending on the type of pattern. I considered creating basic enemy prefabs, and adding the information in runtime, but a huge amount of parameters/possibilities for creating enemies would likely become a nightmare.

[35218-screen+shot+2014-11-14+at+12.21.32+am.png|35218]

Any suggestions for a situation like this? Thanks.

Put all the configurations variables into their own classes and in their own prefabs and just link these. This way, you can create prefabs for common enemy configs seperately from the prefabs of the enemies.

For example for the HomingBullet, create a new script called “BulletConfig” *)

class BulletConfig : MonoBehaviour
{
     // add all the variables from former HomingBullet. But no other game logic.
     public bool fireWhileStill;
     public bool fireWhileMoving;
     ...
}

And in the enemy HomingBullet script

class HomingBullet : MonoBehaviour
{
     public BulletConfig config;
     ...
     // instead of previously accessing "this.fireWhileMoving", use 
     // config.fireWhileMoving and so on..
}

If this gets too performance heavy with too many game objects, you can use ScriptableObjects as base class for the *Config classes. But then you need to start some scripting to be actually able to create these configs… :wink:

Like this:

class BulletConfig : ScriptableObject
{
     ...
}

class HomingBullet : MonoBehaviour
{
     public BulletConfig config;
     ...
     [ContextMenu("Create Config")]
     void CreateConfig()
     {
          config = ScriptableObject.CreateInstance<BulletConfig>();
          #if UNITY_EDITOR
          UnityEditor.EditorUtility.SetDirty(this);
          UnityEditor.AssetDatabase.CreateAsset(config, UnityEditor.AssetDatabase.GenerateUniqueAssetPath("Assets/New BulletConfig.asset"));
          #endif
     }
}

*) All the code is written on the fly without testing. Please fix if I made mistakes :wink: