the title says all. how i can do that?
Not a simple answer. It all depends on the nature of your game. Here is the general outline of what needs to happen so you know where to reasearch:
- Detect contact with something interesting - typically this is done through collision detection, but raycasting or simply evaluating the distance between the player and objects can be used.
- Find out the nature of the interesting item - often this is done through tags on your game objects. Or by attaching a script to the object containing the info.
- Make the object disappear. Typically the object is destoryed, but it can be disabled or moved.
- Set a property in the player that he now has this object.