Im using a free inventory system from the epic games store link is bellow and i am using the use item event to create a hatchet and set a variable and give the hachet back and when that variable is true to detatch the hatchet but im getting the error bellow code, inventory system and error down bellow
Sorry it took me so long to get back to you but i am completely sure i have the right default values for the Bools and im sure that the variable has a reference to the actor that was spawned before it is attached and if that is the problem how do i get a reference to a actor attached to a socket?
Well, a reference to the actor is correct as for attaching / detaching.
But lots of things can happen to the object or variable in between.
This is why I asked whether you’re sure. Being sure and expecting something to be are two very different things
You should use the BP debugging tools to verify and to be sure it’s working as intended.
Because evidently something doesn’t work as you would expect so the task now is to figure out where exactly you loose the reference. Is the object you attached destroyed somewhere? Is the reference removed or overwritten? Is something stored in a different BP instance than where you wanted it?
Lots of things can happen quite easily even to very experienced programmers!
All I can tell you from those pictures at this point is that when that error happens the variable is empty.
And that your code structure or at least the way you access things feel a bit unorganized.
Directly accessing variables and especially manipulating in other classes is not quite ideal as it makes debugging a lot more difficult, requiring you to jump across lots of classes.
Example: Right now you attach the hatchet to the player character from within a class that’s not your player character. This prevents you from storing the variable together with the actor you attached it to and leaves you without a location within the player character, where you could debug this.
I would create two functions within the player character which attach and detach the hatchet. Attaching must provide a hatchet reference. Detaching doesn’t need to. And within the player character you can then store the hatchet itself and check when and where exactly the variable is set, when it’s attached and what exactly happens to this section of code. In exactly one instance of one class.
Oh, I also just noticed that you use attach to component and remove from actor.
Given the error message, you definitely have an issue with your variable but you should also make sure to use functions consistently. Either attach and detach from actor or attach and detach from component. Mixing probably won’t work so well here
ok i moved everything over to the character i got the detach to work now the attach is just making the axe disappears then when i detach it it appears again not being attached so thats working is my socket broken or something i’m very confused now