Why am I getting accessed none from a specified actor variable?

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?

I’ve tried, but I’m getting a block that says Editing this value in a class default object is not allowed

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.

You have a backpack in the world, but you haven’t told your resource gather master BP where it is.

You need to set the variable on Resource_Gather_Master_BP.

Well, in that top screenshot, it doesn’t seem like the backpack variable is set.

Did you set it with the eyedropper/instance in the viewport then?

No, you just set it on the instance of Resource_Gather_Master_BP that you put in the level. In the viewport.

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? :slight_smile:

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. :slight_smile:

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.

It needs to look like this:

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.

You guys are my saviors, seriously. I did have it plugged into the event begin play node, just not in that screenshot.

It works perfectly! Thank you so much!