The asset is an interactive shelf that can be stocked with items. Items can be both taken from the shelf and returned. Add your own items you want, assign them corresponding slots and that's it. Each method of the implementing script contains description what it does and important details. Check it out too.
HOW IT WORKS
The logic is quite simple:
Player approaches the shelf and presses E to get themselves an item. Here we use Trigger_TakeBox set on interaction to get this done. Items on the shelf are ungrabbable (with simulation off). The collision is set to off to to prevent hitting the item from shelf with something else.
Script checks if there is a box on the shelf and if so gives the item.
Once the item is taken it appears in Trigger_ReturnBox trigger gizmo. However it doesn't execute since the box still had 'onShelf' tag. This prevents the issue of box returning to shelf right after it was just taken.
Player now has item in hands and can use it. Once item enters Trigger_CleanOnShelfTag trigger gizmo the item's 'onShelf' tag is removed and item can now be returned to the shelf by entering Trigger_ReturnBox trigger gizmo after that.
Once item without tag 'onShelf' enters Trigger_ReturnBox gizmo it is returned to the shelf, again with simulation and collision off.
There are no limits to 'get item - return item' cycle so it can be repeated as many times as you want.
If there's no more room on shelf to return the item user get the message about it.
If item's shelf tag does not equal shelf's shelf tag the item is not put on the shelf and user gets the message.
Log in or sign up for Devpost to join the conversation.