I’m working on an inventory system and all has been going well, I’m following a tutorial basically to a tee, but I’m getting an error that seems to be saying that it can’t the ‘As BP_Item’ is inaccessible, ‘pending kill or garbage.’ I’ve made sure that the casting is successful, and the game completely works as I need it to, the error is the problem. I don’t know why it cannot access the item when it’s a successful casting. I’ll admit that casting is my weakness in this program, it’s something I have a hard time understanding, so maybe I’m getting it wrong.
I’ve also followed this tutorial step by step and maybe I’m missing something, but they’re not getting the error.
The final “destroy actor” node, if removed, the error does not happen. However I need that node and am not sure what the issue with it is.
Okay, so I checked what variables are valid and the BP Item reference that came from the cast is invalid. I don’t really know how to fix that? do you have any idea why it would be invalid? Also, I don’t understand why it thinks I’ve destroyed the actor already when there were no actors destroyed until the destroy actor node, which is the thing that specifically causes the error. the BPItem reference does work connected to some of the other nodes, though
I’ve tried using a function but I’m not sure where I’d start the function and what parts to keep. When I use the function, the error goes away, but only one item will show up in the inventory.
“Cast To” takes in a type of object, it’s easiest to think about this in the character pov
you have “get player character” which tells the cast to node hey he’s using “BP_ThirdPersonCharacter” and which one… so say there were multiple players all using ThirdPersonCharacter it tells it exactly which instance of the
object and then that allows you to access the information within that specific instance
so in your situation above, your using it correctly, you’ve hit an instance of item with your line trace and then are using the “cast to” to retrieve the information within
To be honest, what i’d do is watch a somewhat better tutorial, the one you sent over seems a touch hard to follow it’s possible you missed some small detail that makes it all work, that’s not obvious from the pictures/video available to us would be happy to look deeper into it if you don’t wish to restart just paste the bp here and send us the link