Unity Project 6: Coin Collection (Code Explained)
This is the script used to control the health bar. When damage is taken the health is decreased. Health bar script This script creates the floating effect that is on the coin by transforming the values on the y-axis by using a Sin wave from its original position. Idle Move script This script allows the player to pick up the coin. Each coin is assigned to a tag named "Player" and therefore whenever the player collides with any object assigned to this tag the particle system is played creating a particle explosion and the object (coin) is 'disabled' causing it to disappear as the particle system is played. The inner and outer mesh are destroyed on collision. Pick up script When the player collides with the object, the health bar decreases by 10. The != operation returns false if its operands are equal, true otherwise. Spike Trap script This script allows the object (coin) to constantly rotate, the speed is defined in ...