WEEK 3 – SCORE SYSTEM & MORE

WHAT

The third week approached and I was tasked to create the score system for our game, along with some other aspects that come with it. For this I needed to create or utilize:

  • A script that would keep track of the players score, and add to the score as long as they are not dead.
  • A HUD (Heads-Up Display) that would communicate the players score.
  • A pickup that would be generated from killing enemies, which would give score when picked up.
  • A crosshair that would follow the players mouse, making it easier to aim.

HOW

I started with creating the crosshair. My initial thought was just to create an object that would only contain a sprite and a script to make it follow the mouse cursor. This proved to be harder than expected. I had no trouble storing the mouse’s position, but placing the transform at that position was apparently a lot harder than I thought it to be. First of all I needed to use a ”ScreenToWorldPoint” to actually register where the mouse was in the game, to make it corelate with its position on the screen. Changing the position of the crosshair to the mouse position would only make it follow the mouse’s movement, but not exactly AT the mouse’s position. I would have to use the ”Lerp” function which linearly interpolates between two vectors. Which in this case was the transform position and mouse position. This would let them know about each other and finally be able to be set to be the same.

I now started to create the score system, which I thought would be very hard, but ended up being a lot easier than expected. A complete twist from the crosshair!
I wanted to make the score increase as the player kept playing, so that the harder the game got, the more score they would get. For that I needed two constants, one that would set how fast the score would increase, and one that would set when the score should begin to increase faster. From there I could could easily keep adding the score, and when it got to the increasion roof, I set the increase rate to be faster, and set the next roof.

74c30408b99dc8834f752b2ecc287cb0

I continued to create the orb pickup that would earn you points when picked up. Not a hard task, I only created an object that would spawn when an enemy was killed, and a collider that would destroy the orb on collision with the player character, and add a score value to the score total.

WHY

We needed the crosshair so that the player could aim properly.

We needed the score so that we could have a sense of progression in the game, where as before it was just an endless onslaught of enemies with no real reward.

We needed the orb pickup because we wanted a risk that you could take to earn a reward if successful. The risk being moving out of your way to grab the orb pickup, and the reward being the extra amount of score gained.

About Arvid Edström

2016 Programming