Download

The best way to handle inheritance between blueprints

Hi,

For a RPG, what would be the best way to handle the blueprints inheritance for characters?

For example, you have a “wizard” class, a “warrior” class and a “thief” class.
The 3 classes have logic in common (such as moving, talking etc…) but each one has its specificities (the wizard can throw spells, the warrior can attack with a sword etc).

So each of my classes has its own mesh/skeleton and blueprint.
I would make a “BaseCharacterBlueprint” to handle the common logic and the "WizardCharacterBlueprint, WarriorCharacterBlueprint will extends the BaseCharacterBlueprint.
That seems pretty simple here.

My question is about the PlayerController. Because I have a PlayerBlueprint to handle action moves.
If the player can choose one of theses classes to play with BUT, these classes are also used for NPC. And now, I’m lost and I don’t know how to do.

I’m trying to spawn dynamically the chosen class and reparent it but it doesn’t work.

My goal would be to have all the classes that can be NPC (AI controlled) and also be chosen by the player.
Also, I’d like to factorise as much as possible.
For example, in my PlayerBlueprint, I have “onClick → attack”. In the Wizard class, “attack” throws a spell, in the “warrior” it attack with the sword etc… (but it’s confort)

Thank you so much for your answers