GameDevHQ 2.5D Cert Requirements Part 3
Objective: Create Collectable Item
We have already created collectables in the previous 2.5D set of post.
We can start by creating a coin using a cylinder primitive shape and editing the scale and rotation. We will also create a coin material and make it a yellow/gold color and attach it to the coin. Next we create a script called coin and attach it to the coin before making the coin a prefab. To start with, lets make the coin rotate as with all good games.
To do this, inside the coin script, create a serialized private float for the rotation speed. Being serialized here helps a lot to find the perfect speed for rotation and testing while in play mode. Next inside the Update method, rotate the transform using the forward direction by the rotation speed by time.
We will add a UI text element to show the coins on screen and create a UIManager script. The UIManager script will need to use the UnityEngine.UI as we did before. After following the same steps as before we have a working coin collectable that is a prefab and works to update the Players coins.