Is using ActorComponent the same as using inheritance?

So I decided to make the project a blueprint based project, because there are more advantages for me rather than using code only. I’m just not sure if what I’m trying to do is correct or if there’s a better way.

So in C++, I’d write a base class Weapon and derive all of my weapons from it, so I could use variables like ammo or weight in all of the other classes without redefining them.

I’m just not sure if I did this correct using blueprints only. So I created an ActorComponent and added a variable ammo there. Then I created an Actor blueprint and just added the component to it. Now I could possibly get the ammo variable by setting the target to the component everytime as shown in the picture.

Or I could use getters and setters, but is that useful for blueprints?

It appears that this more complicated than it would be with code. Is it the same though? I’m not able to open these things in code, so I can’t really tell the differences.

Thanks in advance

On the surface it may appear to give the same result but its actually a bit different. Adding a actor component to each actor is like creating the variable on each actor independant oh inheritence. Though its somewhat similar in that if you change the variables from within the actorcomponent the base one not attached to another actor, then it will affect the values of all the instances that are attached elsewhere.

Its a bit confusing and i probably sisnt explain well.

What if I created a C++ ActorComponent “Weapon” and a C++ Actor “Ak-47” for example. Couldn’t I just derive Ak-47 from Weapon instead then? Would that be better for the efficiency?

Question: Is using ActorComponent the same as using inheritance?

Answer: No.
You can think of Actor Components as pieces of re-usable functionality that you can use on multiple blueprints, or share across projects. Inheritance is handled in Blueprints the same way it is handled in C++.

For example: You can first create BP_Building_Base blueprint. In this blueprint, you can write all common functionality that all buildings share. Right click on that blueprint, and choose Create Child Blueprint Class option. Name new Blueprint BPC_Hangar, in this blueprint you will have access to all parent functions and variables from BP_Building_Base and you can add new functionality to BPC_Hanger that only applies to this building type. That’s blueprint inheritance. See documentation.

That’s what I wanted to know. Thanks!