Assuming you have already created the item game objects and assigned them appropriate colliders, you could create a script attached to each item with the following code:
main.cs548 chars22 lines
This script attaches to each item game object, defines the type and quantity of the item, and detects when the player enters the item's collider trigger. When the player enters the trigger, the item is added to the player's inventory using a custom inventory system, and then the item game object is destroyed from the scene.
You can customize this script further depending on your specific requirements, such as checking if the player's inventory is full before adding the item or playing a sound effect when the item is picked up.
gistlibby LogSnag