Adding values to an array in MyGameInstance from widget blueprint?

Okay. So what I am setting up is an inventory system that runs off an array. I need help figuring out how to reach the array so I can use the Array Add function to place the values into the array so they can be used in the game. Problem is, casting to the array has brought up an assortment of errors that I can see no visible way to fix.


You need an object for casting. Here is how casting works in Blueprints:

If you want to cast to your Inventory class, you need a reference of an object that is type of Inventory class. There are a lot of ways to obtain a reference, but without seeing your setup it is hard to suggest anything. If you are creating the widget from the Player Controller, you might want to get the inventory reference from there and pass it to your widget upon creation through an exposed spawn parameter, so you will be able to use that reference to talk to your inventory, and you won’t even have to cast.