Get Stamina From Object? Do I need to set up an inventory for this to work?

Hey All,

I’m in it for the long hall and i have some really serious issues arising that are preventing me from continuing on the development of the game. I’m trying to set up a can that has stamina in it, so when the player activates animation to drink can, the players stamina increases.
this is what i have going on currently.


What I don’t understand is why i need an object when it seems pretty obvious that im calling that blueprint through “cast to stamina drink, call stamina amount” lol. then apply said amount to current stamina.
Any help would be greatly appreciated.

You don’t need an inventory but you need to setup your references correctly.
Fast and dirty could be Get all actors of class (StaminaDrink), output array with Get 0 then link it to your cast to StaminaDrink, but using get all actors this way is bad.

A cleaner way would be storing that with a variable type StaminaDrink inside your character or game instance, and set it when you pick up the item, so you don’t need to cast or anything.

Another way would be to use data table, it would work with different kind of consumable(mana pot, health pot, etc)

This link shows you how to do something like that with Excel, but you could do it all in game with a custom struct
(Struct Variables in Blueprints | Unreal Engine Documentation)
where you would have the name of the potion, how many points it refunds, etc.