Creators – Finishing Pin Bowling

This week, despite a small group, we finished off the Pin Bowling game. After Christmas we’ll move onto a different game – most likely something 1st person in design.

UI Elements – Text and Buttons

We added two UI Text elements to our game and aligned them to the top left and top right hand corners respectively. One is used for showing the current score and one is used for showing the number of shots remaining. Note that when we add UI elements, Unity automatically adds a Canvas and an EventSystem for us.

UI elements don’t have a standard Transform component, instead they have a RectTransform component which is used to describe their position within their Canvas. To align to a particular location we click on the square below the words “Rect Transform” and select how we’d like to align within the Canvas by clicking one of the options while holding the Shift and Alt keys to set both the pivot and position.

screen-shot-2016-11-29-at-22-41-48

Changes to the Aimer

We updated the aimer so that it now responds to the Up/Down keys to control the strength of our shot. The forward pointing part of the aimer sizes to reflect the currently selected shot strength.

 

Formerly we were using Input.GetAxis(“Fire1”) in the AimerController’s Update() method to check for the fire key being pressed. One of effect of this was that force was applied to the sphere continuously as long as the key was being pressed. This wasn’t the design we wanted. We want the user to only have a limited number of shots and for the sphere to be pushed once only per key press. To accomplish this we switched to checking  Input.GetKeyDown(KeyCode.Space) instead. This method returns true only in the first frame that the key is pressed.

 

Game Manager

We added a GameManager component attached to an empty object also called GameManager. This component is responsible for:

  • Tracking score.
  • Knowing how many shots are allowed.
  • Tracking how many shots have been taken.
  • Showing and hiding the restart button when required.
  • Telling the other parts of the program to reset themselves

 

Download

The completed project can be downloaded from here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s