Class inheritance with blueprints

Hey.

I was wondering if there was any kind of class inheritance in blueprint scripting.

Let’s say I’m building a game with a variety of monsters. I have spiders, zombies, mutated pigs, you name it. All these monsters share some base properties. A very simple example: I want every monster to have a movement speed, basic attack amount of damage, health, stamina, and difficulty. If I were to do this is, let’s say C#, I would just do it like this:



public class Monster
{
    public double basicDamage { get; set; }
    public int MovemenetSpeed { get; set; }
    public double Health { get; set; }
    public double Stamina { get; set; }
    public int Difficulty { get; set; }
}

public class Spider : Monster
{
    // Constructor
    public Spider()
    {
        // Inherited from "Monster" class
        BasicDamage = 20.00;
        MovementSpeed = 5;
        Health = 80.00;
        Stamina = 100.00;
        Difficulty = 1;
        
        // Class specific properties
        IsChild = false;
        PosionDamage = 20.00;
    }

    public bool IsChild { get; set; }
    public double PosionDamage { get; set; }
}

public class MutatedPig : Monster
{
    // Constructor
    public MutatedPig()
    {
        // Inherited from "Monster" class
        BasicDamage = 80.00;
        MovementSpeed = 25;
        Health = 1650.00;
        Stamina = 1650.00;
        Difficulty = 5;

        // Class specific properties
        MutationRemoved = false;
        HasEvolved = false;
    }

    public bool MutationRemoved { get; set; }
    public bool HasEvolved { get; set; }
}


I know that you can do this with C++, but I was just wondering if it’s possible to do with Blueprints? I haven’t been able to find anything online that describes this.

Yeah, it’s possible in blueprints.

Press “Class settings” in Blueprint and it will open a tab with inheritance settings - parent, interfaces and some other options

1 Like

Does this inherit the properties as well? If so, how do I access said properties from the parent class?

in Blueprints everything is by default public (You can set to private/protected in the details panel of a function/variable). In your blueprint under variables (left side of the blueprint editor) you have a list of the Blueprint’s variables.
There’s an eye-icon where you can select “Show Inherited Members” which shows the inherited members.

That’s perfect! Just what I needed. Thanks to both of you :o