Transfer items between inventories

allstar602

New member
Hello,

I am unsure if this is possible with the item and inventory system, but my goal is to transfer an item from the player's inventory / item slot to another object. For example, the player is holding a place-able object like a statue and the goal is to place it on a stand.

At first, I tried to remove the item from the inventory, then parent and move the item visuals to the other object. I didn't have much success with this. I tried several removal and unequip methods from the inventory, but I am unsure. Then I thought it would make sense to use another inventory for the second object, and pass the item to it from the player. Again this didn't seem to do anything.

I am currently in the process of creating my own ability and custom item class, but it would be convenient if it worked with the Item system provided by the asset. That would greatly simplify things since my character currently uses melee weapon items.

Thanks
 
In this case you wouldn't transfer the actual Item setup since the item requires a character. Instead you'd do something like the pickups do where there is a separate model that is used for that particular object. You'd then be able to create an ability which does the transfer.
 
Thanks Justin.

Awesome, I actually implemented something similar to this! I created a PlaceableItem component that holds a prefab for the placed item and I add this component to the Item. This allows me to dynamically spawn objects and place them on the target object. I am using the interact ability and a custom script for my interactable. I detect if the player is holding the correct item, grab the PlaceableItem component, then spawn the placeable prefab on the object. I also remove it from the inventory so player can't place a second one.

I have some ideas to improve this, but it works for my prototype.

I do have one question. Is there a way to completely remove an item and it's visuals from the character? I am going to have a lot of items in my game, and I want to make sure I am cleaning up resources that are no longer used.

Thanks
 
Is there a way to completely remove an item and it's visuals from the character? I am going to have a lot of items in my game, and I want to make sure I am cleaning up resources that are no longer used.

No, UCC is not built that way. Item gameobjects are not really wasteful though, as they only render/use the relevant components as and when necessary (e.g. unequipped items are not rendered). So having a substantial number of items shouldn't be an issue.
 
Thanks Andrew. I appreciate the response.

Everything looks good on my end in regards to place-able items, so I will mark this as solved. Thanks again.
 
Top