How to create Item Classes that inherits each other?

Hello guys,

I recently changed my game engine Unity to Unreal Engine. I am a C# programmer and I was using too much inheritance in my game when I was using Unity. But when language changed to C++, things became confused to me.

I wanna learn that can I create inheritance in C++, like i was doing in C#. I don’t what type of parent I should select(actor,pawn …) but in Unity they derives from nothing.

Inheritence that i am looking for:

For example , i will be able to equip X from my Inventory.

EXTRA question: Am I able to do this system with Blueprints, especially abstract classes with bluprint is possible ?

Sorry for my bad english,

Thank you :))

Hello Skyechuu!

First and foremost, if you are really interested in getting into the nitty gritty realm of C++, you should check out Rama’s C++ Guide.

It will answer many, but not all questions as you come across them. For now though, if you want to do inheritance in C++ you would do something like this:

In your header file:

UCLASS()
class Item : public AActor
{

(This goes on to generated body, constructor, properties, function declarations, etc.)

Then if you wanted you could continue to extend additional classes you could have Weapon : public Item, you could extend from different classes like Pawn, or UObject, or even go with a USTRUCT. Good stuff.

As for your bonus question, This is all easily achievable in blueprints! In fact Epic even made a fairly well thought out and Community Influenced Tutorial on the topic.

Hope this helps get you started!

-Spiris

Thanks a lot for those informations :slight_smile: