Now, to apply the script, either drag the script over to the object you want to attach it to, or select the object and go to "Component" > "Scripts" and select the script you want
One of the scripts that we are going to be using is called 'GemCollect;' this script lets us collect items (or 'gems') throughout our game a'la pacman or super mario. You should all have this script already included in your Scripts folder, so using one of the methods described above, attach the "GemCollect" script to your 'First Person Controller', this tells Unity that your character is able to collect certain objects. Next, to specify which objects are the ones that we can collect, we have to tag them. First select the object that you want to be collectible, then in the 'Inspector', click on the Tag attribute, and select 'gem.' If the tag 'gem' isn't already included, we're going to have to add it by selecting 'Add Tag...'.
This will take us to the Tag Manager; there, we will have to add the tag 'gem' to the first unused 'Element' in the list.
Once you have that done, just go back to the object you want to be collected, and select 'gem' from the Tag menu as described above. Repeat this for all your collectible objects.
No comments:
Post a Comment