Controls: A / D to rotate the camera left or right. W/S to move the ball forward or backwards. Note, the ball moves relative to the camera!

You can grab a potion that lets you knock off enemies more easily, but beware! Grabbing the potion makes you more attractive to the enemy. Double-edged sword.

Purpose: Gameplay mechanics such as enemy waves and powerups

  • Create enemies that chase the player
  • Create powerups for the player to help fight off enemies
    • powerups don't last forever
  • Create waves of increasing amount of enemies

Methodology:

  • Enemies chase the player by taking the player's current position and subtracting it from the current position of the enemy. This gives the direction (Vector3) for the enemy.
  • When the player touches the power up, a OnTriggerEnter method occurs. This includes an If Statement that sets a PowerUp Boolean to true, and start a Coroutine / IEnumerator method. This makes Unity wait for 7 seconds before reading the next line of code, which sets the boolean back to false, and deactivates the powerup  indicator.
  • A OnCollisionEnter method checks whether the player has collided with an enemy and the powerup boolean is true. If so, a force acts on enemy's rigidbody that pushes the enemy away from the player
  • Additional waves of enemies were added with a ForLoop. The ForLoop tells Unity to to spawn as many enemies as the previous wave. A parameter is passed through this ForLoop method that indicates how many enemies were in the previous wave, and to add an additional enemy.

Additional functionality was added:

  • The PowerUp indicator spins rapidly so the player associates with being more powerful.
  • Additionally, grabbing the PowerUp increases the speed of the enemy heading towards the player. The Enemy script checks for the PowerUp Boolean in the Player script.

Notes for future:

A UI system should indicate the number of waves the player has lasted. The UI system should also indicate how many enemies are left remaining. It would also be nice to see a bar that indicates how much time the player has left on the Power Up. Particles effects and audio clips played upon collision of enemies / power ups would be a nice touch.



Leave a comment

Log in with itch.io to leave a comment.