How to do multiple inheritance (or workaround) with Unity?


I’ve run into a bit of a problem… I’m trying to do an “information display on enemy stats” (which will later be turned into a spawn manager script, where I’ve to scale the health, damage and score of the enemy for each wave) but I’ve made 2 different scripts: one for their projectile with their damage output and one script for their health and AI.

But the new script I’m making needs to inheritance from both of these scripts inside my new script, but Unity/C# can’t do multiple inheritance… so what can I do in order to make this work?

My update script is not done (obviously) but it looks like this so far:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class InfiniteSpawnManager : EnemyHealth {

    public Text CurrentEnemyHealthText;
    public Text CurrentEnemyDamageText;
    public Text CurrentEnemyScoreText;

    void Start () {
        CurrentEnemyHealthText.text = "Enemy Health : " + hitPoints.ToString();
        //CurrentEnemyDamageText.text = "Enemy Damage : " + ?.ToString();
        CurrentEnemyScoreText.text  = "Enemy Score : "  + scorePoints.ToString();


I’ve commented out the current enemy damage because that one is supposed to inherititance from another script called “EnemyLaserProjectile”.

Any suggestions on what I can do to fix this mess? Hopefully without having to combine my other 2 scripts into one, which would create some other issues >_>

Try separating the scripts. InifiniteSpawnManager is not a EnemyHealth, so InifiniteSpawnManager doesn’t need to inherit it. Same with EnemyLaserProjectile. EnemyLaserProjectile is not an EnemyDamage, they are two separate behaviors, I presume that Projectile is the animation or graphic and EnemyDamage is simply the damage. So they can each be their own behavior. Ideally a behavior is designed to do a specific task by itself. You could make another script that includes references to two scripts and make them work together.