Greetings! It has now been 3 whole months since I started my 3D platformer game development blog series! Despite some very busy work days and overtime lately in my full-time job, I feel especially proud in being able to keep up with the 3D Platformer course in my spare time, and of course, my commitment to blogging my progress in it every week.
Today, I will finish setting up the mock level (or game scene) by adding just one more pickup object to it before moving onto implementing other elements in the game such as the music, sound effects, and menu screen.
So just what is this shiny, new pickup item that will be added? No doubt, this will be a coin that the player can collect and see how many are in possession! Adding the coin is done in pretty much the same way the heart pickup was added and player health UI implemented in the last two weeks – so feel free to look back at Week #10 and #11 first if you haven’t already!
Before adding the coin to the scene (which will be done last this time), the first thing is to set up the UI to keep track of the number of coins the player has collected. To do this quickly, the ‘HealthImage’ and ‘HealthText’ UI objects in the canvas are duplicated and renamed for the ‘CoinImage’ and ‘CoinText’:
And in the ‘UIManager’ script again, a proper variable is declared to keep track of the player’s coins:
Next, a ‘CoinPickup’ script is created for any coin objects that will be added to the scene:
A coin is then added to the game scene with a collider component, the ‘CoinPickup’ script attached, the coin value assigned, and a unique particle effect created and assigned to it. The coin is then duplicated several times:
Alas, an animation will be added to make the coin spin. Luckily, the process of doing this is quite intuitive as the animation timeline and tools in Unity resemble very much like the ones in Flash and Blender (which I have had some experience doing animation in before):
Taking a closer look at the timeline, the animation slider can be dragged back and forth in the timeline to see the animation play out:
Before running the game, I decided to add another animation for the heart pickup created earlier. Now, let’s see how the animations look in the game!
That’s it for this week’s blog – I hope you enjoyed the read! As I mentioned, next week, I’ll be moving onto other aspects of the game: music, sound effects, and a menu screen. I’m quite excited for this – do stay tuned!