Dear Nathan,
I presume your goals is for your Character to have an Inventory of SteamyItems?
If so a good route to go, assuming you want your items to be ingame actors and thus they have to be extending AActor,
is to make a Dynamic Array in your Character Class that links to world instances of these items.
TArray Inventory;
I think the * in ASteamItems* is part of the UE4 C++ logic you were missing,
you are not storing the actual items in the Inventory, only pointers to the actual items.
To add a SteamyItem to the player’s inventory after it has already entered the world (via SpawnActor or if it was placedi n the world;
//spawn the item in an actor-extending class
ASteamyItem* NewSteamyItem = GetWorld()->SpawnActor(...);
Player->Inventory.Add(NewSteamyItem);
#Instances
The most important thing for your immediate progress is to realize you cannot use things like ASteamyItems::BonusHealth because these are non-instanced versions of the data.
Every AActor has to be instanced / spawned / placed in the world before you can access it’s members.
And then in that case you use →
AInstanceOfSteamyItem->BonusHealth;
#Subclassing SteamyItems
You should probably be sublcassing SteamyItems for each type of Item
so BonusHealth is not a member of SteamyItems, BonusHealth becomes a SUBCLASS of SteamyItems
UCLASS()
class ABonusHealth : public ASteamyItems
Then you could have mutliple BonusHealth Actors with different actual health values
using a member property on BonusHealth like
UPROPERTY()
float HealthValue;
#Game Programming Tip for Items: Sublcass Often!
Store as much of the base logic for items and things that player can pick up and interact with in your base level classes,
then sublcass those base classes for specific types of items like bonus health
so bonus health item would not store the logic for how it can be picked up by player, or the fact that it has a static mesh component representation int he world.
Bonus health item would only store the logic for what happens when player picks it up, and the fact that health is given to the player.
If you subclass your item types a lot
then you can make sweeping changes to your entire game code all at once.
#For example,
if you have every type of item extend a base class like ASteamyItems, and only ASteamyItems has the logic for what happens when player gets close to the item to pick it up (the world static mesh component disappears, and a sound plays, etc),
then if you decide 200 weeks from now, after you have 57 items,
that you ALSO want a standard particle effect to play every time player picks up an item,
well now!
you have to change only 1 class!
your base class for all items!
(Rather than meticulously editing 57 item classes
soooo
subclass things like items often
PS:
If this sufficiently answers your question to get you going in right direction please mark the checkmark by my answer so others know this issue is resolved / well under control