Inventory problems :(

I have been working on a smaoll project of mine and it contains a inventory system made from the tutorial done by Unreal on YouTube. when the inventory was completed i changed a small thing in the code, insted of makig the object invinsible and have no collider i disided to destroy the actor and spawn it when I either pick up the item or drop it.
But when I try to drop the actor the object never spawns in the world what am I missing or doing wrong?

Hard to tell what’s going on without watching the tutorial or seeing more of your BPs.

I’d say you destroyed the actor, which would mean that reference is not valid, so the get class node has no class to get.

Try storing the actor’s class in the inventory rather than storing a reference to the spawned actor (that’s what the blue references are) before destroying the actor, then spawning the actor from the stored class.

Try printing two things after the Spawn Actor node: Print the Resulting actor reference (to be sure it was actually spawned) and print its transform. If your transform returns with a constant location whenever you move, there’s something wrong with the Drop Location Reference

I see. Well if I took away tha whole spawn function It would then make the actor visible and the collider becomes active and tha new transform is at the DropLocation

and it works for others but not me(wich is preatty od).
another idea is that i put the drop function in the Item instead(the spawn actor function), What do tou think?

the print nodes said nothing when the drop function was called

For reference, can you post how you’re picking up/storing these inventory items, and where you call drop from?

Yeah, it’s like I thought.

Modify InventoryStruct to contain an item class, and on begin play call GetClass on self, use ‘set members in struct’ to set the class (purple) variable. Modify your Action Interface to take a class instead of a reference in “DropAction”.

In your UI, when you click to drop (I’m guessing this in in UI) instead of using the reference, just pass in the class variable. Then, in your drop functionality, don’t worry about ‘GetClass’ and just Spawn Actor from the class itself.

*The problem *is that when you store the item in item info, you’re storing a reference to the spawned instance of your item class. The ‘Destroy’ node starts the destruction process, which won’t be processed immediately (I don’t think) so although you typically should call Destroy last- I don’t think this is hurting your BP. Anyway, Destroy finishes pretty quickly and by the time you drop the item, there is no item at that reference- it’s nullptr.

You can test this by dragging the reference which is passed in and using ‘IsValid’ and printing a string depending on the result. Spawn Actor won’t have a class to spawn, your print strings have no value to print. That’s why the strings don’t appear.

wait what was i ganna get from the self in the begining?

Get Class

wait like this?


Now you’ll want to update your interface to use a class for ‘drop item’ and then when you call ‘drop item’ (this is where you’re telling the character what item to drop) you’ll want to pass that class in, instead of the reference. Then, in the actual drop function, you’ll want to just spawn actor from class.

okey this is wery od. I did all you said but when I pick up rhe item it wont get stored in the inventory menu + I changed the DropItem to a class


So this is setting your display text and icon to nothing. You need to either remove these from the node, or set the value in place.

I dont think thats the problem, i found that when the use action is called in the player hud, the target MUST be an actor not a class
any ideas. cus i have none.


Alright, to use the item, you need to spawn an instance of it. So Spawn Actor From Class.

I’m just tabbing over now and then while I work.

ok I’m just guessing.
did mean like this?