Next, you will learn how to alter the player's attributes by creating in-game items that can be picked up by the player. Let's create the prefab in the Unity Editor before proceeding to the script. I did a simple cross-shape prefab using boxes, removed the colliders from the boxes, and attached a sphere collider component to it, which are marked as a trigger. I also set its tag as
Item so that we can use it later. The tag is a very useful functionality in Unity, which allows you to group game objects into the same category for your scripts to identify them during gameplay. For example, you might define
Enemy tags for player-controlled characters and non-player characters respectively.
Instead of creating ...