So, I am trying to make a mechanic where the player character has a backpack that grows as they collect items in their inventory. I have set up the blueprint so that when the player collects something, the backpack actor should be growing in size, but when I try to run it I get the error Accessed None trying to read property Backpack
I created a variable that is connected to the backpack actor, so I’m not sure why it’s having trouble getting referenced. Any ideas?
Would I be able to do that within the blueprints? I tried using “cast to backpack_BP” and then promoting that to a variable, but that didn’t seem to do the trick either, and using the eyedropper is greyed out saying Editing this value in a class default object is not allowed.
That looks like a screenshot from inside the blueprint. I’m talking about the world/level.
Go back to your normal viewport for your level. Then, click on the Gather Master actor that has the variable you need to set. Then, click on the little eye dropper next to the variable in the details panel. Then, click on the specific Backpack actor with the eye dropper.
Does that help?
EDIT: It occurs to me that you may not have a copy of your Resource Gather Master dragged inside your level. If that is the case, you can try using a get all actors of class node inside its blueprint to try to find the one specific backpack that you want (it will be index 0 out of the array if you only have one). I guess I just assumed that you have a Gather Master dragged into the level because the backpack variable is set to instance editable (to allow the eye dropper).
Ohhh, I see what you mean, yeah, I wouldn’t be able to select the specific piece from the viewport. For the setting up the “get all actors of class” node, would it be like this here?
When I go to the dropper to select the backpack, it has the circle with a line through it so it would still be unselectable, yeah? When I go to the dropdown of the default value in the set array, the backpack_bp does appear, but nothing happens when I click on it.
Not quite. You need to use a “Get” node (for arrays) to get the first index of the output array (which is 0). The easiest way to do this is to drag out the array output pin from the Get All Actors of Class node and see if it gives you the option to grab a get node.
Then, you can promote THAT to a variable.
EDIT: Also, the Get All Actors node has to be hooked into an event, but that may be stating the obvious. And, some version of your Resource Master blueprint has to be interacting with your game (but I assume you already have that part covered).
2ND EDIT: Again, this assumes that you only have ONE backpack in your entire level that you need to get. If there is more than one, then you need further logic to figure out which index it is in the array.
Oh, I see. The Resource_Gather_Master_BP isn’t something that I placed into the world, it’s a spawn control that I have setup between pieces of loot and the Resource_Master_BP. The Resource_Gather_Master_BP is what I have been using to add things into my inventory.
That said, I did try to place a Resource_Gather_Master_BP into the viewport to set an instance on, but it just goes in as a lootable item. I also tried setting it in the Resource_Master_BP itself, but it didn’t seem to do me much good.