Accessed none from node

Not sure if this is a bug so I have placed it here, if it is, please place it in the correct place.

I am getting an error every time I press play and my blueprints are not working.
the error is Accessed None “BaseGunRef” from node Spawn Actor from Class in blueprint ASP_Character

I will explain the setup causing the error:

ASP_Character BP :
SpawnActor is inside of a Function: Spawns selected item in inventory.

BaseGunRef = Variable: Reference to a blueprint.

I am trying to use a variable that references a blueprint to call an event when I hit a button, this doesn’t work.
The event graph in my referred to blueprint:
Custom event > prints a string that says “Boom”

The event graph in my ASP_Character.
When I press K > Calls event from ref variable.

Basically the Reference variable and the SpawnActor have no interaction what so ever, yet I get the error.

Can you provide pictures of your blueprints?

Yeah, I just got some, should of done this in the first place, my bad, sorry… haha

And this is the error.

Who sets BaseGunRef?

Are you saving your Items inside a BP reference array?

I hope you don’t just get the item that you find in the world with a line trace, save it to the array and delete it from the world.

UE4 cleans dead pointers every 60 sec. So your inventory gets cleared automaticly every 60 sec. Just something that came to my mind when i saw your BPs. You would rather have multiple arrays. One for the classes, set by hand, one for the indexes of the first array and one for all properties of your items. Than you only save the propertied and the index of the matching class. Later you take the index, get the class and spawn the item back.

Also where do you set your BaseGunRef?

I’m willing to send my project to anyone who is willing to have a look. BaseGunRef is just a variable that I set manually in my ASP_Character Blueprint.

@eXi, I have got 2 bp’s, one for pick up and one for inventory, the inventory stores things such as Display name and a pickup class, the pick up class is a reference to the pick up blueprint, the way it works basically is;

When I press E, it uses a function named UsableActor, which is essentially a line trace, it deletes the in-world object and then spawns one in the inventory, then stores that to an inventory variable(stored in asp_character) which is set to the Inventory blueprint mentioned earlier, I then use an INT to go through my stored objects and select/drop which one I want, is this the wrong way of doing this?

Could you show me the pickup function? I guess you made this from a tutorial since i read the “UsableActor” function a bit often these days :stuck_out_tongue:

The point is, if you just take the in-world object and save it to an array of your item type, it will only save a pointer to this object. If you delete the in-world object, the pointer will stay intact for about 60 sec. UE4 cleans all pointers that don’t have a real inworld actor bound to them after about 60 seconds.

Could be that you are doing it different from what i think, but you could check picking up the object and waiting some time. If i’m right, your inventory should get empty again without doing something. That’s because the pointer is cleared.

Yea, it’s part tutorial and part un-educated mess lol,
Spent around 4 - 5 months learning UE4 and have managed to come up with absolutely nothing to show for it other than errors and glitches haha

I understand what you mean about pointers, I spawn the object before I add it to my array, I’ll show you.

Here’s the pick up.

Here’s the part where I add the Item to my Array.

Öhm, ok so you actualy delete it and spawn it back to 0.0.0 :open_mouth:
Ok i would do this different since you have an object on your world with this.

Your Inventory Class Array holds the BP Classes. You set them manualy.
Now you add an Int Array (called Inventory Items). This is the Inventory itself.

When you pickup an item, you get its class, search for the class in the Inventory Class Array and add the Index where it was found to the Int Array (Inventory Items). Now when you want to spawn the item back to the world, you take the Int value of the slot you want to spawn and use it for a get node of your Inventory Class Array.

e.g.:

Inventory Class:

  • 0 Chair
  • 1 Table
  • 2 Lamp

If you now pick up a table, you search for it inside the Inventory class and add its index to the int array. So for example it will add a 1 to the inventory items array at index 0. Later you take the 1 and get the class back to spawn it.

To save the properties of the item, like name, icon etc, i would make a struct with everything the item has. Than i would make a third array with that struct as type. So would just add all properties of the item to the array when you add it. So an Inventory Properties array would store all information of the Table you added earlier also at index 0. If you spawn the item back later, you just fill in the Struckt. And since its a struct, you only need to connect the struct nodes and not every single property.

Now you could use a 4th array for Stacks that store the information of stacks.

I made a complete inventory with all this and drag and drop already and it works perfectly :smiley: So maybe you give my idea a try.

Wow, okay, yeah, I have followed what you have said and I can now say I have a much better understanding of how it works, the only part I don’t understand is the struct part, if you could explain a little more in depth about the structs, I would appreciate it, if not ill just keep playing with it :slight_smile: thanks for all the help,

This hasn’t solved the error I was getting, but the entire project works without hiccups, not sure what’s causing this error.

Ok, let’s say your item has different values over the time. Like you have a magazine for a weapon or something and you need to save it’s ammo value.

(I would also save the properties, even if you don’t intend to have different values for the same item BP. Maybe you change it later and than it’s a big mess to fix it)

So with this ammo value, there are a few more things you would save with an item:

  • Name
  • Icon
  • Describtion
  • Model
  • Gold Value
  • Max Ammo
  • Current Ammo

Now let’s say you have a parent class for all your items.

This parent class has ALL variables. So for food it would have a hunger value. For a weapon it would have the damage of that weapon and so on.

All child classes, like the magazine, or an apple now get the same variables.

Most of them only need there own but this makes it easier for you to store the properties.

Instead of making all variables single, you make a struct called “Item Properties” in your main class with all the variables. I did this in C++ BlueprintReadWrite, but i guess Structs are the same in BP.

So you have a struct with all the values. Now you just fill them inside your specific item BP. Like giving them a name, a describtion and so on.

Now, with this Struct type that holds all properties, you create an Array of that Struct inside your Player. This makes it easy to save the properties, because you only need to plugin the struct node into the array struct node and not every single variable.

It’s not

Name = Name
Gold = Gold

It’s only

Struct = Struct

Remember to save the properties always to the same index that the item has in the Inventory Items (int) array.

So, now you can pull everything from the struct. If you want to display the items inside a HUD you would just get the struct, break it, uncheck everything you dont need to see of that struct on the left side in the options and get the icon.

I saw that you had a second question that was deleted or changed in my email account. Is it clear now what the Int Array represents?

Since you have all classes, like the table, the chair, the ammo etc inside your Inventory Class Array set by hand, you only need to save the Index where it is inside your Inventory Class Array. So if the Table is in Slot 4, and you have a Table inside your real inventory at Slot 10, you would just save a 4 to Slot 10 inside your Int Array. And also all properties of that Table to the Slot 10 of your Inventory Properties Array. If you want stackable items, you would have another Array that holds numbers for the stacks. So if you have 2 Tables at Slot 10, you would just add 1 to the stacks array.

But with this, you can’t stack unique items, since you can only save one properties struct per slot. So stacking something like an ammo clip wouldn’t be possible, because all would have the same amount of ammo like the first one added.

The adding of stacking items needs a bit logic itself like “When do i stack items, how do i see if there already is an item in my inventory and the stack is not full, etc.”, but this is much more work and i won’t explain that here :smiley:

PS: EPIC :smiley: i need to make a tutorial project for a whole inventory with drag and drop etc and sell it on the market. There are comming more and more people who need this xD

Yeah, eXi you do, i’d defo like to take a look at some of your work, if I had to buy it off the marketplace or not.

The inventory system is brilliant, not found an issue as of yet and it has made extending on the inventory system so much easier with your setup.

Although, it hasn’t fixed my error, would like an Epic member to comment on that or something if they can find the time to do so, it has fixed hundreds of other issues I was having so thanks alot for taking the time to help me, you have taught me quite a bit with that :slight_smile:

Ok back to your BaseGunRef problem.

Where do you set the variable? You need to fill it with the actual object from the scene. I only see that you set the bool inside the real BaseGun with an overlap event but i never see where you set that real BaseGun equal your variable BaseGunRef.

Who starts that overlapping? Is it for placing an object and checking that it doenst overlap with another placed obejct?

Does the error also appear if you delete the part with pressing the button and using the variable?

Could you use an Is Valid Node to check if the Variable is not NULL when you try to use it? Just pull a wire from the BaseGunRef type Is Valid.

Never managed to fix this problem but with massive amounts of help from eXi I was able to find a way around it.

@eXi, First I’ll answer your questions, although the error has gone;
I set the variable when I made it, in the details panel, there wasn’t a node setting it, The gun bp had a box component and an oncollision event that I called from my main character bp, Yes the error still appeared, I don’t actually know what a Valid Node is.

Thank you for your help eXi, using your method I was able to refer to the weapon without having a reference variable, so I was able to delete BaseGunRef and the error no longer persists, again, thank you! :slight_smile:

Is Valid is a node that acts like a branch with the condition that the Variable not empty. Its like saying “if(BaseGunRef)” in c++.

I use this node to check my Charakter from get player character to avoid none acccesed errors. There are two execs from is valid. Is valid and is not valid. You plug in your variable or player character return for example and it checks if the variable is really filled and not empty (none).

If you are fine with an answer, please click the check mark on thr left side of the answer to mark it as resolved.

I am unable to remove this comment